"<script> DELETE FROM xxx WHERE user_id=(SELECT user_id FROM yyy WHERE user_name=#{mobile}) AND product_id IN  <foreach "
+ "collection='deleteIds'"
+ " index='index'"
+ " item='item' "
+ "open='(' separator=',' close=')'>"
+ " #{item}"
+ "</foreach>"
+ "</script>"
报这个错误
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

解决方案 »

  1.   

    你这个SQL写的还包括JS和Mybatis参数,肯定执行报错啊
      

  2.   

    括号里查询出来的结果不止一个吧?把WHERE user_id=改成WHERE user_id in 看看。
      

  3.   

    为什么执行sql语句要 用<script>标签包括,这明显不对。(SELECT user_id FROM yyy WHERE user_name=#{mobile}) AND product_id IN  <foreach "
    + "collection='deleteIds'"
    + " index='index'"
    + " item='item' "
    + "open='(' separator=',' close=')'>"
    + " #{item}"
    + "</foreach>"
    这段代码 返回的结果不止一条数据 。应该将WHERE user_id=  改为WHERE user_id in