Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

preventing duplicates!

Status
Not open for further replies.

tuam1234

Technical User
Feb 6, 2004
52
IE
im populating a dropdown box from a database but dont want any duplicates..

when i use:

check = "SELECT DISTINCT adminPassword FROM admin GROUP BY adminPassword"

i dont get any duplicates but when i try to add another filed to the query as in:

check = "SELECT DISTINCT adminName, adminPassword FROM admin GROUP BY adminName, adminPassword "

i get duplicates..

does anyone know how i can change this 2nd query so that it will work for me????

greatfull for any replies!!
 
that means that there are multiple adminPasswords for a single adminName. Which password would you suggest the query pull? It doesn't work that way.

Are you really putting the password in the drop down? Usually you don't check that until user submission...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
sorry for confusing you. no i dont mean to use a unique password as ud imagine it to be..

il change it to:

check = "SELECT DISTINCT adminName FROM admin GROUP BY adminName"

check = "SELECT DISTINCT adminName, adminAddress FROM admin GROUP BY adminName, adminAddress "

fields in table:
adminName adminAddress
tom galway
john cork
tom dublin
ann cork


i want just want to populate 2 dropdown boxes, one with adminName's and the other with adminAddress's, without any duplicates!!

ie..

dropdown box 1 dropdown box 2
tom galway
john cork
ann dublin

does that help at all??
 
Use two separate SQL queries to create the drop lists. There is no other way to get the results you desire.

check = "SELECT DISTINCT adminName FROM admin ORDER BY adminName"

check = "SELECT DISTINCT adminAddress FROM admin GROUP BY adminAddress "

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
thanks a million, that worked perfectly :>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top