在 Oracle 中以&符號為字首的查詢有效,但在 MySQL 中無效?
在 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) -> ); Query OK, 0 rows affected (0.75 sec)
以下是用@為字首的值的查詢。使用插入命令在表中插入一些記錄。−
mysql> SET @Id = 10001, @Name = 'Carol', @Age =23 ,@Marks =89, @CountryName = 'US'; Query OK, 0 rows affected (0.00 sec) mysql> insert into Student_Information values(@Id, @Name, @Age ,@Marks, @CountryName); Query OK, 1 row affected (0.19 sec)
現在,您可以使用select語句顯示錶中的所有記錄。查詢如下−
mysql> select *from Student_Information;
以下是輸出−
+-----------+-------------+------------+--------------+--------------------+ | StudentId | StudentName | StudentAge | StudentMarks | StudentCountryName | +-----------+-------------+------------+--------------+--------------------+ | 10001 | Carol | 23 | 89 | US | +-----------+-------------+------------+--------------+--------------------+ 1 row in set (0.00 sec)
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP