Davie33 Posted August 21, 2013 Share Posted August 21, 2013 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 https://forums.phpfreaks.com/topic/281424-mysql-error-clause-ambiguous/ Share on other sites More sharing options...
kicken Posted August 21, 2013 Share Posted August 21, 2013 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 https://forums.phpfreaks.com/topic/281424-mysql-error-clause-ambiguous/#findComment-1446086 Share on other sites More sharing options...
Davie33 Posted August 21, 2013 Author Share Posted August 21, 2013 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 . Link to comment https://forums.phpfreaks.com/topic/281424-mysql-error-clause-ambiguous/#findComment-1446089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.