Reputation: 195
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";
Upvotes: 1
Views: 2546
Reputation: 74216
"I asked the client to change the column to have an underscore but this column is linked across many tables in there database."
Since the column name cannot be changed as outlined in comments, give this a try.
appliances.`Location ID` = location.ID) WHERE `Location ID`
or
`appliances`.`Location ID` = location.ID) WHERE `Location ID`
Check for errors also. I do not know which API is being used to connect with, nor on which platform.
Upvotes: 2