ehp ehp - 3 months ago 12
MySQL Question

How to select a column name with space between in mysql on liunx/ubuntu

I am working on a project where another developer created table with column names like

'Business Name'
. That is a space between two words. I am a Linux user now; If I run a
SELECT
statement with 'Business Name' it says there is no columns with name 'Business'.

How can I solve this problem?

Thanks

Answer

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

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.