I am a MSSQL user now I am converting my database to MySQL,
I am writing following query in MySQL.
select col1 as [My Column] from table1
Error : You have an error in sql syntax
I am a MSSQL user now I am converting my database to MySQL,
I am writing following query in MySQL.
select col1 as [My Column] from table1
Error : You have an error in sql syntax
You have a syntax error because the escape character (delimiter) is different from MSSQL
. You need to use backtick
instead of brackets. eg,
select col1 as `My Column` from table1
MySQL => backtick
MSSQL => bracket
Remove []
select col1 as MyAliasName from table1
Or
select col1 as `My Alias Name` from table1
Aliasses work the same in mysql, but you need to use other delimiters: Instead of:
select col1 as [My Column] from table1;
use
select col1 as ´My Column´ from table1;
or without any delimiters if the table/column-name doesn't contain any special characters:
select col1 as MyColumn from table1;