Hello all i am new to sql,

iam having a requirement where i need to have a distinct value from the result lets say

example,

contacts table

id name
--- --------
1 john
2 jason
3 mark

address table

id address conid
-- ------ -----
1 newlane1 1
2 newlane2 2
3 newlane3 3
4 newlane4 1
5 newlane5 1
6 newlane6 2

city table

id cityname Addid
-- -------- ------
1 LA 1
2 NY 2
3 NY 4
4 NY 5
5 ZS 3
6 KY 6

these are the tables
Now i need to show up all the combined records at one place for a contact,
my query is,

SELECT CON.NAME,ADD.ADDRESS,CTY.CITYNAME FROM CONTACTS CON,ADDRESS ADD,CITY CTY WHERE

CON.ID=ADD.CONID AND CTY.ADDID=ADD.ID AND CON.ID=1

it shows up like this

NAME ADDRESS CITYNAME
---- ------- ---------
john newlane1 LA
john newlane4 NY
john newlane5 NY

this is ok but now WHAT I WANT to show up the distict values of a particular filed when

user selects like if he selects CITYNAME
I NEED THE RESULT to be

NAME ADDRESS CITYNAME
---- ------- ---------
john newlane1 LA
john newlane4 NY

it doesn't matter which duplicate row to be deleted but it has to show up the distinct

values with combination of all the columns.

can you please help me out...

Thanks in advance,
Farooq.

i suggest you to use join you can get information about how to use different form of sql joins by searching sql join in wikipedia

can you please help me with the query?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.