Search code examples
sqldatabasemysql-error-1052

#1052 - Column 'noMyKid' in where clause is ambiguous


SELECT *, DATEDIFF(CURDATE(),tarikhmohon) AS hari
FROM mohon a 
INNER JOIN tblstatus_tak_lengkap b on a.noMyKid=b.nomykid 
WHERE noMyKid=130902100437

I have tried that SQL but I got an error.

#1052 - Column 'noMyKid' in where clause is ambiguous.

I can't find the problem.


Solution

  • Column noMyKid is present is both tables. You should tell the server on what table the column you want to filter, eg

    WHERE a.noMyKid = 130902100437
    

    or

    WHERE b.noMyKid = 130902100437
    

    Whatever you use, it doesn't matter since you are using INNER JOIN.