richrock Posted April 24, 2008 Share Posted April 24, 2008 Hi, I'm having a noob day and can't suss out what should be a simple problem... SELECT * FROM bid_auctions LEFT JOIN bids ON bids.userid WHERE bids.userid = ".$usrid." Returns information from two tables, which is getting all the info I need. However, in both tables there is an 'id' row. I need to get only the id numbers from bid_auctions not bids. How??? I am completely stumped. ??? Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/ Share on other sites More sharing options...
fenway Posted April 24, 2008 Share Posted April 24, 2008 You can't... * isn't psychic. You'll need to alias one of the id fields. BTW, you should really name your PK bid_id and user_id... that way, both the PK and FK have the same name, and you won't ever have name collisions. Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/#findComment-526039 Share on other sites More sharing options...
richrock Posted April 25, 2008 Author Share Posted April 25, 2008 Sorry for sounding a little dull (this is my first project after all)... What are PK and FK? I get the whole thing about aliases. Guess this is going to be a long string, as there's quite a lot of info to be extracted from these tables... Thanks Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/#findComment-526892 Share on other sites More sharing options...
fenway Posted April 25, 2008 Share Posted April 25, 2008 Primary Key and Foriegn Key. Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/#findComment-527026 Share on other sites More sharing options...
aschk Posted April 25, 2008 Share Posted April 25, 2008 I'll point you to the area of fault: "...JOIN bids >>> ON bids.userid <<< WHERE..." ON what? bids.userid IS TRUE, = "darth vader", has rare unconditioned tropical disease? I'll leave it for you to figure out p.s. simple tip: join on something Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/#findComment-527049 Share on other sites More sharing options...
fenway Posted April 25, 2008 Share Posted April 25, 2008 I'll point you to the area of fault: "...JOIN bids >>> ON bids.userid <<< WHERE..." ON what? bids.userid IS TRUE, = "darth vader", has rare unconditioned tropical disease? I'll leave it for you to figure out p.s. simple tip: join on something Yeah, that too... but the * issue still applies. Link to comment https://forums.phpfreaks.com/topic/102689-multiple-id-columns-in-joined-statement/#findComment-527098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.