Jump to content

Mysql error clause ambiguous


Davie33

Recommended Posts

Hi can any one see what is wrong with this query please I have tryed a few ways of doing it but can't get it to work.

Thanks in adavnce.

 

    Error No: 0 - MySQL error Column 'id' in where clause is ambiguous
    Query: "SELECT shouts.id,shouts.text,shouts.date,shouts.name,user.id,user.username,user.avatarfile,user.useavatar FROM shouts LEFT JOIN user ON shouts.name = user.username WHERE shouts.id = id ORDER BY shouts.date = 'date' ASC LIMIT 20"

Link to comment
Share on other sites

You have an ID column in both tables, so you need to be explicit about which table's ID column you are referring to. In your WHERE clause, you have the condition:

 shouts.id = id
The second id column reference has no table prefix so mysql does not know which id column it should use.
Link to comment
Share on other sites

Hi i think i have sorted it by doing this...

"SELECT shouts.text,shouts.date,shouts.name,user.id,user.username,user.avatarfile,user.useavatar FROM shouts LEFT JOIN user ON shouts.name = user.username ORDER BY shouts.date = 'date' ASC LIMIT 20"

 

Plus i don't see any errors in my log :).

Edited by Davie33
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.