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条)

报告相同问题?

悬赏问题

  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏