dpxf81245 2014-01-10 16:16
浏览 17
已采纳

比较两列时的MySQL select语句[关闭]

You helped a lot with my previous problem a few days ago so i thought I'd ask for help with my current issue.

I have a table named orders with quote and payment fields

I'm trying to get it to display all the data where quote=payment so i did the following query:

SELECT * FROM Orders WHERE quote = '$payment'

However, it doesn't work, but if i do something like:

SELECT * FROM Orders WHERE quote = '10'

Then it works perfectly, any ideas why it doesn't seem to want to work when comparing two columns, but works when I add the number directly into the query? Both columns are int as well. Thanks for any help.

  • 写回答

3条回答 默认 最新

  • dongzhi8487 2014-01-10 16:17
    关注

    If I understand you correct you are trying to find rows where the values in the quote and payment columns match. If so, you just need to compare the column names (in other words, I'm not sure where the $payment variable is coming into play here. Maybe the $ is just a typo out of habit?).

    "SELECT * FROM Orders WHERE quote = payment"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源