Click here to Skip to main content
15,889,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a table market_place_design which has different market places and designs.
1 design exists in different market places.
I have another table temp which has only column design filled in it.
Now after joining the tables i am getting multiple data for a single design whereas i need only 1 top(1) to be precise.
But top 1 does not work if i am selecting multiple design.
Posted
Comments
Maciej Los 13-May-13 4:24am    
What is your query?
Please, provide more details (example data), if you want our help.
AmrutaKanvinde 13-May-13 4:30am    
"SELECT * from Tmp Tmp
inner JOIN MARKET_PLACE_DESIGN_RELATION MPDR ON MPDR.MARKET_PLACE_DESIGN=Tmp.MarketDesign "

table TMP contains only 4 rows and the result of this query should also return only 4 rows.
That is my requirement.however i am getting 12 because market_place_design_relation has for 1 design 3 rows(of different market places)


this is the main table
TransType VoucherNo ImportDuty DutyApp MarketDesign Design
LP NULL NULL NULL P06827-W NULL
LP NULL NULL NULL P12010-10KW NULL

and the result set with redundant values
CODE MARKET_PLACE_DESIGN
BuyUSA P06827-W
AmazonUS P06827-W
eBayUSA P06827-W
DD.COM P06827-W
BuyUSA P12010-10KW
AmazonUS P12010-10KW
eBayUSA P12010-10KW
DD.COM P12010-10KW


Distinct does not work.I tried already.

Thanks
Maciej Los 13-May-13 4:32am    
and example data...

Use "Improve question" widget!
gvprabu 13-May-13 4:38am    
you can use Group by and Having for this.

1 solution

Try this:
SQL
SELECT DISTINCT *
FROM Tmp Tmp inner JOIN MARKET_PLACE_DESIGN_RELATION MPDR ON MPDR.MARKET_PLACE_DESIGN=Tmp.MarketDesign


http://www.w3schools.com/sql/sql_distinct.asp[^]
 
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