如何在MySQL中选择带有空格的列名 [英] How to select a column name with a space in MySQL

查看:64
本文介绍了如何在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中选择带有空格的列名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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