Click here to Skip to main content
15,915,848 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi every one i want to fetch the data from two different table in a single query, but i am unable to fetch the unique data. this is my query executed successfully, but i unable to fetch the unique tittle name.this is my query..

Select Top 4 PC.Title,IM.ImageName,IM.ImageTitle,IM.ImageLocation,IM.ImageId from Images   IM inner join PhotoCategory PC ON PC.AutoId = IM.Category


my frist table that is PhotoCategory and second is images. In my first table has autoid and title. In Images title is common, in which i send the autoid, i am fetching the title with the help of category. query is executed successfully, but it give the same title name, and i want to unique data.
Please can any one help me.....
Thanks in advance...
Posted
Comments
Karthik Harve 24-Nov-11 7:17am    
Is "Category" is unique in "Images" table..??? I think multiple titles are because of the mutiple values of Category in Images table.

1 solution

Hi Friends Thanks For Reply, I have solved my problem..
Sollution is..

select IM.ImageName,IM.ImageLocation,IM.ImageTitle,IPT.Title from Images IM inner join (select PC.autoid,PC.Title , max(IG.Autoid)as 'IGID'from PhotoCategory PC inner join Images IG on IG.category = PC.Autoid group by PC.autoid ,PC.Title)IPT ON IPT.IGID = IM.AutoId
 
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