jbradley04 Posted December 20, 2009 Share Posted December 20, 2009 Hello, I am trying to populate a dropdown menu from multiple tables in a db... here is what I have... not quite working.. mysql_query("SELECT DISTINCT d.position, o.position, k.position, q.position FROM football_q AS q, football_d AS d, football_o AS o, football_k AS k WHERE d.userID='$userID' OR o.userID='$userID' OR k.userID='$userID' OR q.userID='$userID'"); Can Anyone tell me what I am doing wrong or is this even possible? I am trying to return a position if it is in the DB but if there are 7 QB's I just want it to list one... Hence the distinct Thanks for your help! J Quote Link to comment https://forums.phpfreaks.com/topic/185798-distinct-with-a-join-is-it-possible/ Share on other sites More sharing options...
Mchl Posted December 20, 2009 Share Posted December 20, 2009 What exactly are you trying to do (except killing your database with four unlimited cross joins)? What is in your tables, and what exactly do you want to get? Quote Link to comment https://forums.phpfreaks.com/topic/185798-distinct-with-a-join-is-it-possible/#findComment-981069 Share on other sites More sharing options...
jbradley04 Posted December 20, 2009 Author Share Posted December 20, 2009 I am trying to populate a dropdown menu for "positions" They positions that could be populated are in four different tables. So If a user has "position 3" and "position 5" and "position 9" This would grab those positions and place them in a dropdown menu so they can choose the one they want to view,... The problem comes in that they psitions can be in any one of four tables and there could be multiple entries, ie. "position 3" could be in table 4 times, but I only want one displayed! I know, it is as clear as mud! Hope this hels though! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/185798-distinct-with-a-join-is-it-possible/#findComment-981076 Share on other sites More sharing options...
Mchl Posted December 20, 2009 Share Posted December 20, 2009 You probably should look into UNION statement Quote Link to comment https://forums.phpfreaks.com/topic/185798-distinct-with-a-join-is-it-possible/#findComment-981080 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.