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

报告相同问题?

悬赏问题

  • ¥15 设计一个温度闭环控制系统
  • ¥100 关于加载卡的问题有能知道这个要怎么处理吗?
  • ¥100 rtmpose姿态评估
  • ¥15 java 通过反射找路径下的类,打包后就找不到
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错
  • ¥15 hbuildex运行微信小程序报错
  • ¥15 关于#python#的问题:我知道这个问题对你们来说肯定so easy
  • ¥15 wpf datagrid如何实现多层表头