如何在MySQL中选择带空格的列名

How to select a column name with a space in MySQL(如何在MySQL中选择带空格的列名)
本文介绍了如何在MySQL中选择带空格的列名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在处理一个项目,其中另一位开发人员创建了一个表,其列名称类似于 'Business Name'.那是两个词之间的空格.如果我运行带有企业名称"的 SELECT 语句,它会显示没有名称为企业"的列.

I am working on a project where another developer created a table with column names like 'Business Name'. That is a space between two words. If I run a SELECT statement with 'Business Name' it says there is no column with name 'Business'.

我该如何解决这个问题?

How can I solve this problem?

推荐答案

通常第一步是首先不要这样做,但如果已经这样做,那么您需要求助于正确引用您的列名:

Generally the first step is to not do that in the first place, but if this is already done, then you need to resort to properly quoting your column names:

SELECT `Business Name` FROM annoying_table

通常这些东西是由使用过 Microsoft Access 之类的东西并且总是使用 GUI 来做他们的事情的人创建的.

Usually these sorts of things are created by people who have used something like Microsoft Access and always use a GUI to do their thing.

这篇关于如何在MySQL中选择带空格的列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)