“&”号在Oracle中工作。要在MySQL中工作,请使用@,如以下语法所示-
SET @yourVariableName1 = yourValue, @yourVariableName2 = yourValue, @yourVariableName3 =yourValue,.........N; insert into yourTableName values(@yourVariableName1,@yourVariableName2,@yourVariableName3,........N);
为了理解上述语法,让我们创建一个表。创建表的查询如下-
mysql> create table Student_Information -> ( -> StudentId int, -> StudentName varchar(100), -> StudentAge int, -> StudentMarks int, -> StudentCountryName varchar(10) -> );
这是带有以@开头的值的查询。使用insert命令在表中插入一些记录。-
mysql> SET @Id = 10001, @Name = 'Carol', @Age =23 ,@Marks =89, @CountryName = 'US'; mysql> insert into Student_Information values(@Id, @Name, @Age ,@Marks, @CountryName);
现在,您可以使用select语句显示表中的所有记录。查询如下-
mysql> select *from Student_Information;
这是输出-
+-----------+-------------+------------+--------------+--------------------+ | StudentId | StudentName | StudentAge | StudentMarks | StudentCountryName | +-----------+-------------+------------+--------------+--------------------+ | 10001 | Carol | 23 | 89 | US | +-----------+-------------+------------+--------------+--------------------+ 1 row in set (0.00 sec)