MySQL 'user_id' in where clause is ambiguous problem

后端 未结 4 1666
逝去的感伤
逝去的感伤 2020-11-28 16:49

How can I correct the problem I keep getting from the code below which states \'user_id\' in where clause is ambiguous. Thanks for the help in advance.

4条回答
  •  情话喂你
    2020-11-28 16:58

    The solution is to select each column explicitly everywhere. Don't use user.* and user_info.* in your select list, either:

    SELECT u.user_id, u.user_fudge, ui.foo, ui.bar
    FROM user u
    INNER JOIN user_info ui
        ON ui.user_id = u.user_id
    WHERE u.user_id = '$user_id';
    

提交回复
热议问题