如何在MySQL中将“ from”作为列名?

使用反引号将“ from”视为列名,因为它是保留字。现在,我们将创建一个表,其保留字由反引号包围-

create table DemoTable1810
     (
     `from` varchar(20)
     );

使用插入命令在表中插入一些记录-

insert into DemoTable1810 values('US');
insert into DemoTable1810 values('UK');
insert into DemoTable1810 values('AUS');

使用select语句显示表中的所有记录-

select `from` from DemoTable1810;

这将产生以下输出-

+------+
| from |
+------+
| US   |
| UK   |
| AUS  |
+------+
3 rows in set (0.00 sec)