You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL查询无返回结果排查:列名引用方式错误导致数据不匹配

问题解决

你的查询语句存在两个核心问题:

  • 列名引用错误:列名License Number包含空格,你用单引号'License Number'包裹时,SQL会将其识别为字符串常量而非列名。带空格的列名需要用反引号(`)包裹才能正确识别。
  • 数据类型可能不匹配:如果License Number是字符串类型,数值5286必须用单引号包裹,否则会因类型转换失败无法匹配记录。

修正后的查询语句分两种情况:

  • 若License Number为数值类型:
select * from test where `License Number` = 5286;
  • 若License Number为字符串类型:
select * from test where `License Number` = '5286';

另外补充:show database需改为show databases(复数形式),不过这不是导致查询无结果的原因。

内容的提问来源于stack exchange,提问作者Gao

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 20:18:09