duanjunao9348 2015-12-10 10:33
浏览 135
已采纳

如何在mysql的where子句中使用select查询?

I am trying to retrieve everything from a table where the invoiceNo is distinct.So here is what I tried.

SELECT * FROM  `selected_items` WHERE 'invoiceNo' IN 
(SELECT DISTINCT(invoiceNo) AS invoiceNo FROM selected_items`);

When I try this in php myadmin I get the following warning with no output.

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 2.

And when I run my php script from my android app it returns nothing.Is there a place where I can check my query like php code checker.

I am new to programming so any help and suggestion is welcome.Thank you :)

  • 写回答

4条回答 默认 最新

  • duandeng7132 2015-12-10 11:13
    关注

    As Saty already mentioned in a comment: you probably mean:

    SELECT * FROM selected_items GROUP BY invoiceNo;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?