Home > Mobile >  [ERROR]: Column 'status' in where clause is ambiguous
[ERROR]: Column 'status' in where clause is ambiguous

Time:04-11

cursor.execute(
"SELECT * FROM `xplt_cases` LEFT JOIN `dgn_cases` ON dgn_cases.rid = xplt_cases.rid WHERE `status`=%(checker)s",
{
  'checker': status
})

I'm new to MySQL and I'm trying to join two tables together to grab the results, but I'm getting an error saying: Column status in where clause is ambiguous.

"status" is my function argument.

CodePudding user response:

the error Column 'status' in where clause is ambiguous means that the 2 tables you joined in your query have both a column named status that's why Mysql tells you that the column status is ambiguous

You can fix this by indicating the table which status column you want to use in your query. Examples;

  xplt_cases.`status`=%(checker)s"

or

   dgn_cases.`status`=%(checker)s"

CodePudding user response:

Well, it seems both of your tables have a status column. Try prefixing it with a table name(alias):

SELECT * FROM `xplt_cases` x LEFT JOIN `dgn_cases` ON dgn_cases.rid = xplt_cases.rid 
WHERE x.`status`=%(checker)s
  • Related