找到 4219 篇文章 关于 MySQLi
136 次查看
如果按照以下语法正确编写,反引号将起作用:update `yourTableName` set `yourTableName`.`yourColumnName`='yourNewValue' where yourCondition;让我们首先创建一个 -mysql> create table `DemoTable_1401` -> ( -> Name varchar(20) -> ); Query OK, 0 rows affected (0.52 sec)使用 insert 插入一些记录到表中 -mysql> insert into `DemoTable_1401` values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into `DemoTable_1401` values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into `DemoTable_1401` values('Bob'); Query OK, 1 row affected (0.12 sec)使用 select 显示表中的所有记录 -mysql> select * from `DemoTable_1401`;这将产生... 阅读更多
3K+ 次查看
每个关系可以有一个或多个候选键。这些候选键之一称为主键。每个候选键都符合主键的条件。因此,主键的候选者称为候选键。要在 MySQL 中实现候选键,请将多个列设置为唯一键。这些键将符合候选键的条件,如以下语法所示:alter table yourTableName add unique key anyName(yourColumnName1, yourColumnName2);让我们首先创建一个 -mysql> create table DemoTable1400 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(40), -> Age int -> ); Query ... 阅读更多
46 次查看
不,可以在不添加新记录的情况下获取下一个主键。让我们首先创建一个 -mysql> create table DemoTable1399 -> ( -> StudentId int NOT NULL AUTO_INCREMENT, -> PRIMARY KEY(StudentId) -> ); Query OK, 0 rows affected (0.53 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1399 values(); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1399 values(); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1399 values(); Query OK, 1 row affected (0.07 sec)使用 select 显示表中的所有记录 -mysql> select ... 阅读更多
422 次查看
让我们首先创建一个 -mysql> create table DemoTable1398 -> ( -> Marks int -> ); Query OK, 0 rows affected (0.50 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1398 values(78); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1398 values(82); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1398 values(90); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1398 values(98); Query OK, 1 row affected (0.12 sec)使用 select 显示表中的所有记录 -mysql> select * from DemoTable1398;这将产生以下输出:+-------+ | ... 阅读更多
616 次查看
对于日期比较,您可以使用 STR_TO_DATE()。以下是语法:select * from yourTableName where str_to_date(yourColumnName, 'yourFormatSpecifier') > curdate();让我们首先创建一个 -mysql> create table DemoTable1397 -> ( -> AdmissionDate varchar(40) -> );s Query OK, 0 rows affected (0.97 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1397 values('01/04/2019'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1397 values('27/09/2019'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1397 values('29/09/2018'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1397 values('29/09/2019'); Query OK, 1 row affected (0.08 sec)显示 ... 阅读更多
230 次查看
让我们首先创建一个 -mysql> create table DemoTable1396 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> Name varchar(40), -> Age int -> ); Query OK, 0 rows affected (0.93 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1396(Name, Age) values('Chris', 21); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1396(Name, Age) values('David', 24); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable1396(Name, Age) values('Bob', 26); Query OK, 1 row affected (0.40 sec)使用 select 显示表中的所有记录 -mysql> select * from DemoTable1396;这 ... 阅读更多
146 次查看
让我们首先创建一个 -mysql> create table DemoTable1 -> ( -> Id int -> ); Query OK, 0 rows affected (1.06 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1 values(1); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1 values(NULL); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1 values(2); Query OK, 1 row affected (0.34 sec) mysql> insert into DemoTable1 values(3); Query OK, 1 row affected (0.13 sec)使用 select 显示表中的所有记录 -mysql> select * from DemoTable1;这将产生以下输出:+------+ | ... 阅读更多
194 次查看
要对多个列进行排序,请使用 ORDER BY GREATEST()。让我们首先创建一个 -mysql> create table DemoTable1395 -> ( -> Value1 int, -> Value2 int, -> Value3 int -> ); Query OK, 0 rows affected (0.79 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1395 values(40, 50, 60); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable1395 values(90, 56, 80); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1395 values(10, 20, 30); Query OK, 1 row affected (0.11 sec)使用 select 显示表中的所有记录 -mysql> select ... 阅读更多
187 次查看
对于千位数,使用 MySQL FORMAT()。让我们首先创建一个 -mysql> create table DemoTable1394 -> ( -> Amount decimal(7, 3) -> ); Query OK, 0 rows affected (0.68 sec)使用 insert 插入一些记录到表中 -mysql> insert into DemoTable1394 values(60); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1394 values(2355.4); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable1394 values(456); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1394 values(8769); Query OK, 1 row affected (0.13 sec)使用 select 显示表中的所有记录 -mysql> select * from DemoTable1394;这 ... 阅读更多
浏览量 172
以下是语法:−select * from yourTableName where yourColumnName like '%a%a%a%';让我们首先创建一个表:−mysql> create table DemoTable1393 -> ( -> CountryName varchar(40) -> ); Query OK, 0 rows affected (0.71 sec)使用insert语句在表中插入一些记录:−mysql> insert into DemoTable1393 values('andorra'); Query OK, 1 row affected (0.50 sec) mysql> insert into DemoTable1393 values('australia'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1393 values('argentina'); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable1393 values('austria'); Query OK, 1 row affected (0.26 sec)使用select语句显示表中的所有记录:−mysql> ... 阅读更多