I have the below table
ID First Name Last Name
1 Ruby Rails
2 Loop Western
The columns have a space in them and so when I write a query like
$sql = "SELECT * FROM Persons where [Last Name] = 'Western' ";
it throws the error
Error, could not list tables MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Last Name] = 'Western'' at line 1
How do I get this to work?
If this is valid, you would have to use backticks:
but if you ask me, don’t do this. It’s begging for trouble somewhere along the way. Just use an underscore or CamelCase:
LastName