Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have Two Tables

SQL
CREATE TABLE SALES_MASTER
(
	bill_no INT PRIMARY KEY,
	cust_Id INT NULL,
	cust_name VARCHAR(50) NULL,
	total_bill_amount DECIMAL(12,2) NOT NULL
)

CREATE TABLE PAYMENT_DETAILS
(
	bill_no INT PRIMARY KEY,
	pay_mode INT NULL,
	pay_amt DECIMAL(12,2) NOT NULL
)


1 Record In SALES_MASTER:
bill_no  cust_Id  cust_name   total_bill_amount
1000     2424     Deepak      40000

2 Record In PAYMENT_DETAILS:
bill_no  pay_mode pay_amt
1000       C      20000
1000       Q      20000

when i join both tables using
SQL
SELECT bill_no,cust_Id,cust_name,total_bill_amount,pay_mode,pay_amt
FROM SALES_MASTER SM,PAYMENT_DETAILS PD
WHERE SM.bill_no = PD.bill_no

I get following Result
bill_no  cust_Id  cust_name   total_bill_amount  pay_mode pay_amt

1000     2424     Deepak      40000              C        20000

1000     2424     Deepak      40000              Q        20000

I want This Result
bill_no  cust_Id  cust_name   total_bill_amount  pay_mode pay_amt

1000     2424     Deepak      40000              C        20000

                                                 Q        20000


Please help me thanks in Advance
Posted
Updated 27-Nov-11 18:57pm
v2

What you want does not make sense in the context of a SQL query. The query is doing it's job correctly.

You can however merge the results in your datagrid of choice and not show the same column values.
 
Share this answer
 
try to use
SQL
DISTINCT
keyword after
SQL
SELECT


hope it helps,,,

mark this as answer if it helps you.
thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900