找到 4379 篇文章 关于 MySQL
74 次查看
让我们首先创建一个表 - mysql> create table DemoTable ( Number int ); Query OK, 0 rows affected (0.79 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(56); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(78); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values(89); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(98); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values(91); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values(96); Query OK, 1 row affected ... 阅读更多
219 次查看
让我们首先创建一个表 - mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100) ); Query OK, 0 rows affected (0.55 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(Name) values('John Smith'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name) values('Carol Taylor'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name) values('John Doe'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(Name) values('Chris Brown'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(Name) values('John Brown'); Query OK, 1 row ... 阅读更多
224 次查看
让我们首先创建一个表 - mysql> create table DemoTable ( Download varchar(100) ); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('120 Gigabytes'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('190 Gigabytes'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('250 Gigabytes'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('1000 Gigabytes'); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生以下输出 -+----------------+ ... 阅读更多
207 次查看
要从列表中获取特定的 varchar ID,可以使用 FIND_IN_SET()。让我们首先创建一个表 - mysql> create table DemoTable ( Id varchar(255) ); Query OK, 0 rows affected (0.51 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values('10, 100, 1000'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('101, 120, 2'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('3, 4, 5'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生 ... 阅读更多
594 次查看
为此,您可以使用 IS NULL 属性。让我们首先创建一个表 - mysql> create table DemoTable ( ProductPrice int, ProductQuantity int, TotalAmount int ); Query OK, 0 rows affected (1.22 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable(ProductPrice, ProductQuantity) values(100, 2); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(ProductPrice, ProductQuantity) values(500, 4); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(ProductPrice, ProductQuantity) values(1000, 10); Query OK, 1 row affected (0.21 sec)使用 select 语句显示表中的所有记录 - mysql> select *from DemoTable;这将产生 ... 阅读更多
658 次查看
要使一对列唯一,请使用 UNIQUE 和 ALTER TABLE 命令。以下是语法 - alter table yourTableName add unique yourUniqueName(yourColumnName1, yourColumnName2, ...N);让我们首先创建一个表 - mysql> create table DemoTable ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFirstName varchar(100), StudentLastName varchar(100), StudentAge int, StudentPhoneNumber varchar(20) ); Query OK, 0 rows affected (0.81 sec)以下是使 MySQL 中一对列唯一的查询 - mysql> alter table DemoTable add unique DemoTable_unique_StudentFirstName_StudentPhoneNumber(StudentFirstName, StudentPhoneNumber); Query OK, 0 rows affected (0.40 sec) Records: 0 Duplicates: 0 Warnings: 0在 ... 阅读更多
876 次查看
让我们首先看看这种情况何时可能发生。创建一个表并设置列名和数据类型,但不设置大小 - mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar, LastName varchar ); ERROR 1064 (42000): 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 ', LastName varchar )' at line 4您可以通过为 varchar 数据类型提供大小(如 varchar(100))来更正上述错误。这将解决问题。让我们修复它 ... 阅读更多
121 次查看
要使用保留关键字“Key”,请使用反引号符号的概念。在这里,对于我们的示例,我使用列名 key,它需要在列名周围使用反引号符号。让我们首先创建一个表 - mysql> create table DemoTable ( `Key` int ); Query OK, 0 rows affected (0.67 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(101); Query OK, 1 row affected (0.55 sec) mysql> insert into DemoTable values(110); Query OK, 1 row affected (0.28 sec) mysql> insert ... 阅读更多
1K+ 次查看
让我们首先创建一个表 - mysql> create table DemoTable ( Money DECIMAL(7, 2) ); Query OK, 0 rows affected (0.58 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable values(100.67); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(199.33); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(500); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values(400); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values(800); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 - mysql> ... 阅读更多
浏览量 163 次
为此,您可以使用 GROUP BY HAVING 子句。让我们首先创建一个表 -mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.52 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(Value) values(600); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Value) values(600); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Value) values(800); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(Value) values(800); Query OK, 1 row affected (0.09 sec)显示表中的所有记录 ... 阅读更多