找到 4219 篇文章 关于 MySQLi
2K+ 次浏览
您可以使用 LPAD() 以及 rand() 和 floor() 来生成 6 位随机数。让我们先创建一个表:mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values(1); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(2); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(3); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable values(4); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(5); Query OK, ... 阅读更多
2K+ 次浏览
您可以为此使用 NOW()。以下是语法:select * from yourTableName where yourColumnName> now();让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, expiryDateOfMedicine datetime ); Query OK, 0 rows affected (0.55 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable(expiryDateOfMedicine) values('2019-04-27 11:29:00'); Query OK, 1 row affected (0.36 sec) mysql> insert into DemoTable(expiryDateOfMedicine) values('2019-04-26 10:39:21'); Query OK, 1 row affected (0.41 sec) mysql> insert into DemoTable(expiryDateOfMedicine) values('2019-04-28 11:30:10'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(expiryDateOfMedicine) values('2019-04-29 12:44:11'); ... 阅读更多
462 次浏览
您可以为此使用 AS 命令。让我们先创建一个表:mysql> create table DemoTable ( Name varchar(20) ); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.18 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable;这将产生以下输出:+------+ | Name | +------+ | John | +------+ 1 row in set (0.00 sec)以下是创建第二个表的查询。mysql> create table DemoTable2 ( Name varchar(20) ... 阅读更多
390 次浏览
为此使用 NOT LIKE。让我们先创建一个表:mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentFullName varchar(40) ); Query OK, 0 rows affected (0.66 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable(StudentFullName) values('JohnSmith'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(StudentFullName) values('John Doe'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(StudentFullName) values('Adam Smith'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(StudentFullName) values('CarolTaylor'); Query OK, 1 row affected (0.19 sec)使用 ... 阅读更多
159 次浏览
您需要为此使用 GROUP BY。让我们先创建一个表:mysql> create table DemoTable ( StudentFirstName varchar(20) ); Query OK, 0 rows affected (0.74 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values('John'); Query OK, 1 row affected (1.34 sec) mysql> insert into DemoTable values('Carol'); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected (0.25 sec) mysql> ... 阅读更多
1K+ 次浏览
如果您没有指定 unsigned,则 bigint 将是有符号的。如果您指定 unsigned,则 bigint 将是无符号的。让我们先创建一个表:mysql> create table DemoTable ( Number bigint, // 有符号 Number2 bigint unsigned // 无符号 ); Query OK, 0 rows affected (1.08 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values(18446744073709551615, 18446744073709551615); ERROR 1264 (22003): Out of range value for column 'Number' at row 1 mysql> insert into DemoTable values(9223372036854775807, 18446744073709551615); Query OK, 1 row affected (0.28 sec)使用 select 语句显示表中的所有记录:mysql> ... 阅读更多
962 次浏览
为了使用 MySQL 检查表是否已存在于数据库中,您可以使用 INFORMATION_SCHEMA.TABLES。以下是语法:SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = ‘yourDatabaseName’ AND TABLE_NAME = ’yourTableName’;让我们实现上述语法以检查表是否已存在于数据库中。情况 1:当表存在时:mysql> SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'sample' AND TABLE_NAME = 'DemoTable';这将产生以下输出:+--------------+ | TABLE_NAME | +--------------+ | DemoTable | +--------------+ 1 row in set (0.01 sec)情况 2:当表 ... 阅读更多
327 次浏览
您可以为此使用 REGEXP。让我们先创建一个表:mysql> create table DemoTable ( Value text ); Query OK, 0 rows affected (1.28 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values('645st'); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable values('765stp'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('665tcp'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('606cpp'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable;这将产生 ... 阅读更多
408 次浏览
您可以将 BINARY 与 LIKE 运算符一起使用。让我们先创建一个表:mysql> create table DemoTable ( Header text ); Query OK, 0 rows affected (1.09 sec)使用 insert 命令在表中插入记录:mysql> insert into DemoTable values('Programming tutorials on MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('programming in Java language'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Program in C language'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('pRograMMing in Python language'); Query OK, 1 row affected (0.41 sec)显示 ... 阅读更多
93 次浏览
为此,请使用 COUNT() 函数。让我们先创建一个表:
mysql> create table DemoTable
(
StudentFirstName varchar(20)
);
Query OK, 0 rows affected (0.53 sec)
使用 insert 命令在表中插入记录:
mysql> insert into DemoTable values('Larry');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('John');
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Larry');
Query OK, 1 row affected (0.10 sec)
mysql> insert into DemoTable values('David');
Query OK, 1 row affected (0.16 sec)
mysql> insert into DemoTable values('Bob');
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('Larry'); ... 阅读更多