找到 4219 篇文章 关于 MySQLi
449 次浏览
为此,使用带有 ORDER BY 的 CASE 语句。让我们首先创建一个表 - mysql> create table DemoTable1937 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1937 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values('Adam'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1937 values(''); Query OK, 1 row affected (0.00 sec) ... 阅读更多
2K+ 次浏览
要执行多个插入操作,语法如下 - insert into yourTableName(yourColumnName1, yourColumnName2, yourColumnName3, ..N) select yourValue1 as yourColumnName1, yourValue2 as yourColumnName2, yourValue3 as yourColumnName3, ......N union select yourValue1 as yourColumnName1, yourValue2 as yourColumnName2, yourValue3 as yourColumnName3, ......N . . N要理解上述语法,让我们创建一个表 - mysql> create table DemoTable1936 ( StudentId int, StudentName varchar(20), StudentCountryName varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1936(StudentId, StudentName, StudentCountryName) select 1001 as StudentId, 'Chris' as StudentName, 'US' ... 阅读更多
218 次浏览
为此,使用 RLIKE 并按以下语法过滤记录 &Minus;select * from yourTableName where yourColumnName rlike 'yourValue1|yourValue2';让我们首先创建一个表 - mysql> create table DemoTable1935 ( Subject varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1935 values('MySQL'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('Python'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('MongoDB'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1935 values('SQL Server'); Query OK, 1 row affected (0.00 ... 阅读更多
477 次浏览
要获取平均值,请使用 AVG() 并将其与 DISTINCT 一起使用以从不同的记录中计算。让我们首先创建一个表 - mysql> create table DemoTable1934 ( StudentName varchar(20), StudentMarks int ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1934 values('Chris', 56); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1934 values('Chris', 56); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1934 values('David', 78); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1934 values('David', 78); Query OK, 1 row affected ... 阅读更多
1K+ 次浏览
让我们首先创建一个表 - mysql> create table DemoTable1933 ( ClientName varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1933 values('Chris Brown'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('Adam Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('John Doe'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable1933;这将产生 ... 阅读更多
314 次浏览
使用 ORDER BY 来修复记录,然后显示 select * from yourTableName order by yourColumnName1=yourValue desc, yourColumnName2;让我们首先创建一个表 - mysql> create table DemoTable1932 ( UserName varchar(20), ShippingDate date ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1932 values('Chris', '2018-10-12'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1932 values('David', '2019-04-11'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1932 values('Mike', '2016-12-04'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1932 values('Carol', '2017-12-26'); Query OK, 1 ... 阅读更多
639 次浏览
对于特定格式的月份和年份,请使用 DATE_FORMAT() 以及 STR_TO_DATE()。让我们首先创建一个表 - mysql> create table DemoTable1931 ( ShippingDate varchar(40) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1931 values('10-11-2017'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1931 values('31-01-2019'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1931 values('02-02-2018'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1931 values('10-06-2013'); Query OK, 1 row affected (0.00 sec)使用 select 显示表中的所有记录 ... 阅读更多
483 次浏览
为此,您可以使用 date_add()。让我们首先创建一个表 - mysql> create table DemoTable1930 ( DueTime datetime ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1930 values('2017-10-21'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2019-12-14'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2018-11-26'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1930 values('2014-06-16'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable1930;这将 ... 阅读更多
563 次浏览
要重置主键,首先使用 TRUNCATE 表,然后使用 ALTER TABLE。让我们首先创建一个表 - mysql> create table DemoTable1929 ( UserId int NOT NULL AUTO_INCREMENT, PRIMARY KEY(UserId) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录 - mysql> insert into DemoTable1929 values(); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1929 values(); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1929 values(); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录 - mysql> select * from DemoTable1929;这将 ... 阅读更多
3K+ 次浏览
要在存储过程中向表中插入数据,语法如下 - create procedure yourProcedureName(OptionalParameter) begin insert into yourTableName() values(yourValue1, yourValue2, ...N); end要理解上述语法,让我们首先创建一个表 - mysql> create table DemoTable1928 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(20), Age int ); Query OK, 0 rows affected (0.00 sec)以下是创建存储过程的查询 - mysql> delimiter // mysql> create procedure insert_demo(IN Name varchar(40), IN Age int) begin insert into DemoTable1928(Name, Age) values(Name, Age); end // Query OK, ... 阅读更多