查询具有带有空格的列名的表? [英] Querying a table that has column names with spaces?

查看:97
本文介绍了查询具有带有空格的列名的表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在尝试获取表名称中带有空格的列数据.

I am currently trying to get table data that have column names with spaces.

客户端创建的数据库的列名带有空格,该表已与其他表连接,我尝试在[]和''中使用列名,但似乎不起作用.我的查询如下:

The client has created the database with column names having spaces, the table is joined across other tables, I have tried using the column name in [] and '' but don't seem to work. My query is as follows:

$query = "SELECT appliances.*, location.* FROM (appliances LEFT JOIN location ON appliances.Location ID = location.ID) WHERE Location ID = 11";

推荐答案

我要求客户将列更改为下划线,但此列已链接到该数据库中的许多表."

由于无法按注释中所述更改列名,请尝试一下.

Since the column name cannot be changed as outlined in comments, give this a try.

appliances.`Location ID` = location.ID) WHERE `Location ID`

`appliances`.`Location ID` = location.ID) WHERE `Location ID`

  • 请注意,这些是刻度线,而不是常规的单引号.
  • 还要检查是否有错误.我不知道正在使用哪个API进行连接,也不知道在哪个平台上进行.

    Check for errors also. I do not know which API is being used to connect with, nor on which platform.

    • 此(示例)答案基于MySQL而不是MSSQL,因为该问题被标记为mysql.

    这篇关于查询具有带有空格的列名的表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆