找到关于 MySQLi 的 4219 篇文章
714 次浏览
假设当前日期是 2019-08-03。现在,我们将看到一个示例并创建一个表 −mysql> create table DemoTable840(DueDate datetime); Query OK, 0 rows affected (0.66 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable840 values('2019-08-9'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable840 values('2019-07-5'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable840 values('2019-08-10'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable840 values('2019-07-13'); Query OK, 1 row affected (0.10 sec)使用 select 语句显示表中的所有记录 −mysql> select *from DemoTable840;这将产生… 阅读更多
70 次浏览
要设置特定记录排序,请使用 ORDER BY LIKE。让我们首先创建一个表 −mysql> create table DemoTable808(Value varchar(100)); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable808 values('smith'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable808 values('Adamsmith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable808 values('Carolsmith'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable808 values('smithJohn'); Query OK, 1 row affected (0.16 sec)使用 select 语句显示表中的所有记录 −mysql> select *from DemoTable808;这将产生以下输出 −+------------+ ... 阅读更多
3K+ 次浏览
让我们首先创建一个表 −mysql> create table DemoTable807( ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientName varchar(100), ClientCountryName varchar(100) ); Query OK, 0 rows affected (0.64 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable807(ClientName, ClientCountryName) values('Chris', 'UK'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable807(ClientName, ClientCountryName) values('David', 'AUS'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable807(ClientName, ClientCountryName) values('Robert', 'US'); Query OK, 1 row affected (0.74 sec) mysql> insert into DemoTable807(ClientName, ClientCountryName) values('Mike', 'ENG'); Query OK, 1 row affected (0.14 sec)显示所有记录 ... 阅读更多
145 次浏览
要部分匹配,请使用 LIKE 运算符。让我们首先创建一个表 −mysql> create table DemoTable806( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentSubject varchar(100) ); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable806(StudentName, StudentSubject) values('Chris', 'Java in Depth With Data Structure'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable806(StudentName, StudentSubject) values('Robert', 'Introduction to MySQL'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable806(StudentName, StudentSubject) values('Bob', 'C++ in Depth With Data Structure And Algorithm'); Query OK, 1 row affected ... 阅读更多
3K+ 次浏览
让我们首先创建一个表 −mysql> create table DemoTable805(LoginDate datetime); Query OK, 0 rows affected (0.63 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable805 values('2019-01-31 12:45:20'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable805 values('2017-11-01 10:20:30'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable805 values('2016-03-12 04:10:00'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable805 values('2018-12-24 05:01:00'); Query OK, 1 row affected (0.13 sec)使用 select 语句显示表中的所有记录 −mysql> select *from DemoTable805;这将产生以下输出 −+---------------------+ | LoginDate ... 阅读更多
352 次浏览
为此,您需要使用 ORDER BY 来排序记录。使用 RAND() 获取随机记录,并使用 LIMIT 5,因为我们只想显示 5 条随机记录。让我们首先创建一个表 −mysql> create table DemoTable773 (StudentId int); Query OK, 0 rows affected (0.59 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable773 values(100); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable773 values(200); Query OK, 1 row affected (0.87 sec) mysql> insert into DemoTable773 values(300); Query OK, 1 row affected (1.59 sec) mysql> insert into DemoTable773 values(400); Query OK, ... 阅读更多
228 次浏览
要查找表中的备选记录,您需要使用 OR 条件,如下面的语法所示 −select *from yourTableName where yourColumnName=yourValue1 OR yourColumnName=yourValue2…...N;让我们首先创建一个表 −mysql> create table DemoTable772 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), Age int ); Query OK, 0 rows affected (0.76 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable772(Name, Age) values('Chris', 21); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable772(Name, Age) values('Robert', 26); Query OK, 1 row affected (0.19 sec) ... 阅读更多
80 次浏览
使用 BETWEEN 查找加入日期和解雇日期之间的日期和时间。NOW() 用于获取当前日期和时间以进行比较。让我们首先创建一个表 −mysql> create table DemoTable771 ( Joiningdate datetime, Relievingdate datetime ); Query OK, 0 rows affected (1.15 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable771 values('2016-01-21', '2016-09-23'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable771 values('2019-01-21', '2019-09-23'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable771 values('2017-04-01', '2018-12-31'); Query OK, 1 row affected (0.20 sec) ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 −mysql> create table DemoTable770 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value int ); Query OK, 0 rows affected (0.65 sec)使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable770(Value) values(10); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable770(Value) values(90); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable770(Value) values(160); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable770(Value) values(450); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable770(Value) values(560); Query OK, 1 row affected ... 阅读更多
3K+ 次浏览
为电话号码设置国家代码意味着连接。您可以使用 CONCAT() 函数实现此操作。让我们首先创建一个表:
mysql> create table DemoTable769 (MobileNumber varchar(100));
Query OK, 0 rows affected (0.54 sec)
使用 insert 命令在表中插入一些记录:
mysql> insert into DemoTable769 values('8799432434');
Query OK, 1 row affected (0.24 sec)
mysql> insert into DemoTable769 values('9899996778');
Query OK, 1 row affected (0.15 sec)
mysql> insert into DemoTable769 values('7890908989');
Query OK, 1 row affected (0.21 sec)
mysql> insert into DemoTable769 values('9090898987');
Query OK, 1 row affected (0.20 sec)
使用 select 语句显示表中的所有记录:
mysql> ... 阅读更多