search

Home  >  Q&A  >  body text

There is an ambiguous where clause for column 'status'

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 get results, but I get an error message: The column status in the where clause is ambiguous.

"status" is my function parameter.

P粉127901279P粉127901279281 days ago429

reply all(2)I'll reply

  • P粉066224086

    P粉0662240862024-02-26 16:25:42

    Hmm, it looks like both of your tables have a status column. Try prefixing it with the table name (alias):

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

    reply
    0
  • P粉850680329

    P粉8506803292024-02-26 13:56:33

    ErrorColumn 'status' in where clause is ambiguous means that the 2 tables you joined in the query have a column named status, which is Why Mysql tells you that column status is ambiguous

    You can solve this problem by indicating which status column in the table to use in the query. Example;

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

    or

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

    reply
    0
  • Cancelreply