- Forums
- MySQL
- mysql error - column 'category_id' in where clause is ambiguous
This Page Contains information about mysql error - column 'category_id' in where clause is ambiguous By wallpaperama in category MySQL with 1 Replies. [912], Last Updated: Sat May 18, 2024
wallpaperama
Fri Dec 26, 2008
1 Comments
2287 Visits
hi i need to know i am getting this error when i run a query on mysql with php?
well, if you are also asking this question to yourself, i know the answer. i will show you the fix.
that is, how i was able to fix it.
basically if you are getting this error its because you probably have a mispelling on your mysql query that you are trying to run with php.
it happened to me, i was going crazy trying to find out what was going on.
if you are getting this, its human error, you need to check carefully your mysql query. really!
if you're mysql query its pretty long, you just have to be patient and check it, make sure you put commas and you spelled the tables and fields correctly.
fist step is change the fields to the wild for example i have this query:
$sql = "SELECT name,date,locotion,status,age,password,category_id,id FROM users WHERE usersid=256";
as you can see from my query, have misspelled location, i put locotion instead. so one way to make sure you dont have a mispelled field is to use the wild card (*) so this is how i would chage mysql query:
$sql = "SELECT * FROM users WHERE usersid=256";
see if it fails, if it doesnt fail, then it means you mispelled a field.
in my situation, this is how mysql query looked like:
$sql = "SELECT w.name,w.locotion,w.status,c.name,w.link,w.id,category_id c.date, FROM users u, cats c WHERE c.category_id =w.id AND w.status='active'";
as you can see from my query, i should dont have a comman after c.category_id, so once i put the command, i didnt get the error anymore
hope that helps