找到 4219 篇文章,关于 MySQLi
81 次查看
为此,使用 LTRIM() 和 RTRIM(),因为名称相似但左侧和右侧的空格分配不同。例如,“ John “ 和 “John”。让我们首先创建一个表 -mysql> create table DemoTable614 (EnterName varchar(100), ReennterName varchar(100)); Query OK, 0 rows affected (0.97 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable614 values(' John ', 'John'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable614 values('Carol ', 'Bob'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable614 values('David ', 'David'); Query OK, 1 row affected (0.23 sec)显示所有记录来自 ... 阅读更多
90 次查看
让我们首先创建一个表 -mysql> create table DemoTable613 (Id int, Age int, isMarried tinyint(1)); Query OK, 0 rows affected (0.54 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable613 values(100, 29, 0); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable613 values(200, 22, 0); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable613 values(300, 30, 1); Query OK, 1 row affected (0.19 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable613;这将产生以下输出 -+------+------+-----------+ | Id | Age | isMarried | +------+------+-----------+ ... 阅读更多
306 次查看
对于条件,使用 IF()。以下是语法 -IF(yourCondition, trueStatement, falseStatement);让我们首先创建一个表 -mysql> create table DemoTable612 (Number1 int, Number2 int, Score int); Query OK, 0 rows affected (0.47 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable612 values(10, 20, 1000); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable612 values(30, 40, 500); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable612 values(50, 70, 1200); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable612 values(100, 120, 400); Query OK, 1 row affected (0.16 sec)显示所有记录来自 ... 阅读更多
266 次查看
让我们首先创建一个表 -mysql> create table DemoTable611 (DOB date); Query OK, 0 rows affected (0.99 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable611 values('1996-04-21'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable611 values('2001-01-31'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable611 values('2004-12-21'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable611 values('2000-02-03'); Query OK, 1 row affected (0.14 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable611;这将产生以下输出 -+------------+ | DOB | ... 阅读更多
83 次查看
让我们首先创建一个表 -mysql> create table DemoTable610 (SubjectName varchar(100)); Query OK, 0 rows affected (0.63 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable610 values('MySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable610 values('Java'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable610 values('MySQL'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable610 values('MongoDB'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable610 values('MySQL'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable610 values('MySQL'); Query OK, 1 row affected (0.08 sec) mysql> ... 阅读更多
670 次查看
为此,使用 SUBSTR()。以下是语法 -update yourTableName set yourColumnName=substr(yourColumnName, 2);让我们首先创建一个表 -mysql> create table DemoTable607 (Value varchar(100)); Query OK, 0 rows affected (0.69 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable607 values('83967364'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable607 values('10939432'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable607 values('932111'); Query OK, 1 row affected (0.16 sec)显示表中使用 select 语句的所有记录 -mysql> select *from DemoTable607;这将产生以下输出 -+----------+ | Value | +----------+ | 83967364 ... 阅读更多
99 次查看
让我们首先创建一个表 -mysql> create table DemoTable606 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(100)); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable606(FirstName) values('John'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable606(FirstName) values('Robert'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable606(FirstName) values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable606(FirstName) values('David'); Query OK, 1 row affected (0.13 sec)显示表中使用 select 语句的所有记录 -mysql> select *from DemoTable606;这将产生以下输出 -+----+-----------+ ... 阅读更多
112 次查看
为此,您可以使用 DATE_FORMAT()。让我们首先创建一个表 -mysql> create table DemoTable605 (DueDate date); Query OK, 0 rows affected (0.57 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable605 values('2019-01-21'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable605 values('2019-02-23'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable605 values(curdate()); Query OK, 1 row affected (0.15 sec)显示表中使用 select 语句的所有记录 -mysql> select *from DemoTable605;这将产生以下输出 -+------------+ | DueDate | +------------+ | 2019-01-21 | | 2019-02-23 | | 2019-03-04 ... 阅读更多
158 次查看
对命令分隔的参数使用 FIND_IN_SET()。让我们首先创建一个表 -mysql> create table DemoTable604 (Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Title varchar(100)); Query OK, 0 rows affected (0.51 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable604(Title) values('MySQL'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable604(Title) values('C++'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable604(Title) values('MongoDB'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable604(Title) values('Java'); Query OK, 1 row affected (0.14 sec)显示表中使用 select 语句的所有记录 -mysql> select *from DemoTable604;这 ... 阅读更多
3K+ 次查看
为此,您可以使用 SHOW COLUMNS 或 INFORMATION_SCHEMA.COLUMN。让我们首先创建一个表 -mysql> create table DemoTable603 ( ClientId int NOT NULL AUTO_INCREMENT, ClientName varchar(100), ClientAge int, ClientAddress varchar(100), ClientCountryName varchar(100), ClientEducationDetails varchar(200), PRIMARY KEY(ClientId) ); Query OK, 0 rows affected (0.59 sec)案例 1 - 使用 SHOW 命令以下是查找 MySQL 中列名称的查询 -mysql> SHOW COLUMNS FROM DemoTable603;这将产生以下输出 -+------------------------+--------------+------+-----+---------+----------------+ | Field ... 阅读更多