Welcome to WebmasterWorld Guest from 54.221.30.139

Forum Moderators: open

Message Too Old, No Replies

MySQL - How to get DISTINCT or UNIQUE ?

How to get the 4th field to be DISTINCT among 4 fields?

     

bgb76

1:35 am on Aug 27, 2012 (gmt 0)

5+ Year Member



Hi Masters,

I'm facing this delima that among 4 fields, I want the 4th field to be DISTINCT. How?

cno
cfname
cphone
cemailid -- DISTINCT

select DISTINCT cemailid, cno,cfname,cphone from rform (not working)

Kindly help me, Please...

Thanks in Advance.
Bharadwaj

brotherhood of LAN

2:05 am on Aug 27, 2012 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



This should work,

SELECT select cemailid, cno,cfname,cphone
FROM rform
GROUP BY cphone

See [dev.mysql.com...]

bgb76

2:16 am on Aug 27, 2012 (gmt 0)

5+ Year Member



Thank You Bro,

No avail. I tried. 544 records on distinct on "cemailid" after adding another field, the record shoot upto 612.

Still trying.

Thanks for help.

brotherhood of LAN

2:31 am on Aug 27, 2012 (gmt 0)

WebmasterWorld Administrator brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



GROUP BY field will most definitely give you distinct values. Maybe you should check for trailing newlines & spaces in those fields.

staceybrown281

12:56 pm on Sep 16, 2012 (gmt 0)



Better use Group by Syntax that using the keyword DISTINCT.

Dijkgraaf

4:17 am on Sep 26, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bortherhood of LAN is right in principle, but wrong in detail ;-), if you want to be distinct on cemailid you need to group on cemailid

SELECT select cemailid, cno,cfname,cphone
FROM rform
GROUP BY cemailid
 

Featured Threads

Hot Threads This Week

Hot Threads This Month