Jump to content

multiple ID columns in joined statement


richrock

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.