Click to See Complete Forum and Search --> : distinict query
forkirun
August 18th, 2003, 05:23 AM
I want distinct result but its still giving me duplicate record
query is below
SELECT RegisteredUser.*, UsersGroup.Group
FROM RegisteredUser RIGHT JOIN UsersGroup ON RegisteredUser.Email = UsersGroup.Email;
RegisteredUser is a table ,its primary key is a test feild and both table are in one to many relationship....
Please tell me what could be the problem
Praj
August 18th, 2003, 05:50 AM
Originally posted by forkirun
I want distinct result but its still giving me duplicate record
query is below
SELECT RegisteredUser.*, UsersGroup.Group
FROM RegisteredUser RIGHT JOIN UsersGroup ON RegisteredUser.Email = UsersGroup.Email;
RegisteredUser is a table ,its primary key is a test feild and both table are in one to many relationship....
Please tell me what could be the problem
Please rephrase your problem,
What do you exactly want in your Query?
Praj
forkirun
August 19th, 2003, 07:22 AM
i need not the duplicate record ..
to eliminate duplicate record we just write the distinct keyword right.. but here by putting distincnt ,.. its still giving me duplicate records
womalley
August 21st, 2003, 06:28 AM
Originally posted by forkirun
i need not the duplicate record ..
to eliminate duplicate record we just write the distinct keyword right.. but here by putting distincnt ,.. its still giving me duplicate records
When you use the DISTINCT key word, you need to make sure that everything in your SELECT statement is DISTINCT.
In other words. Lets say that I have a Table tblItem
In this table are Items that are on my web site. Now those Items have catagories..
So
Item Number 1 belongs to Catagory 2
Item Number 2 belongs to Catagory 2
Item Number 3 belongs to Catagory 4
and so on...
Now if I were to try to do a DISTINCT SELECT from this table
I could do this.
SELECT DISTINCT CatagoryID FROM tblITem
or I could do this
SELECT DISTINCT ItemID FROM tblItem
But I cant do this
SELECT DISTINCT CatagoryID,ItemID FROM tblItem
because the ItemID and CatagoryID combo is unique. Because of that it Satisfies the DISTINCT condition
Hope this helped
Will
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.