找到 4219 篇文章 关于 MySQLi
86 次查看
我们将看到一个示例并创建一个表,其中我们将 StudentId 列设置为 AUTO_INCREMENT = 100 并也使用了 ZEROFILL -mysql> create table DemoTable ( StudentId int(7) ZEROFILL NOT NULL AUTO_INCREMENT, PRIMARY KEY(StudentId) )AUTO_INCREMENT=100; Query OK, 0 rows affected (0.48 sec)使用 insert 命令在表中插入一些记录。现在,如果什么都不插入,则值将从 101(auto_increment)开始,并且左侧的其余值将填充 0,因为我们在上面创建表时设置了 ZEROFILL -mysql> insert into DemoTable values(); Query OK, 1 row affected ... 阅读更多
89 次查看
让我们首先创建一个表 -mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, PlayerName varchar(100), PlayerScore int ); Query OK, 0 rows affected (0.97 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(PlayerName, PlayerScore) values('Chris', 780); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Sam', 1100); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Mike', 900); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(PlayerName, PlayerScore) values('Bob', 890); Query OK, 1 row affected (0.15 sec) mysql> insert into ... 阅读更多
400 次查看
要进行格式化,请使用 DATE_FORMAT()。让我们首先创建一个表mysql> create table DemoTable ( LoginTime time ); Query OK, 0 rows affected (0.48 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('13:10'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('20:08'); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable values('10:55'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('16:40'); Query OK, 1 row affected (0.11 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;这将产生以下输出 -+-----------+ | ... 阅读更多
577 次查看
要从列值中仅删除第一个单词,请使用 substring()。以下是语法 -select substring(yourColumnName, locate(' ', yourColumnName)+1) AS anyAliasName from yourTableName;让我们首先创建一个表 -mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.50 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Java in Depth'); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable values('C++ is an object oriented programming language'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('MySQL is a relational database'); Query OK, 1 row affected (0.17 ... 阅读更多
99 次查看
假设存储的价格包含 20% 的销售税。现在,让我们首先创建一个表 -mysql> create table DemoTable ( Price int ); Query OK, 0 rows affected (1.09 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(40); Query OK, 1 row affected (0.07 sec) mysql> insert into DemoTable values(80); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(60); Query OK, 1 row affected (0.18 sec)使用 select 语句显示表中的所有记录 -mysql> select ... 阅读更多
102 次查看
让我们首先创建一个表 -mysql> create table DemoTable ( Title text ); Query OK, 0 rows affected (0.39 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Introduction to MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Introduction to Java'); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to Python'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('Introduction to SQL'); Query OK, 1 row affected (0.09 sec) ... 阅读更多
172 次查看
要显示,请使用 DESC 命令或 information_schema.columns。让我们首先创建一个表并设置选项 -mysql> create table DemoTable ( Color SET('RED', 'GREEN', 'BLUE', 'YELLOW') ); Query OK, 0 rows affected (0.47 sec)案例 1以下是使用 DESC 命令获取 SET 可用选项列表的查询 -mysql> desc DemoTable;这将产生以下输出 -+-------+------------------------------------+------+-----+---------+-------+ | Field | Type | Null | Key | ... 阅读更多
848 次查看
要插入随机数,请使用 MySQL 中的 RAND() 函数。让我们首先创建一个表 -mysql> create table DemoTable ( Value int ); Query OK, 0 rows affected (0.46 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values(30); Query OK, 1 row affected (0.08 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;这将产生以下输出 -+-------+ | Value | +-------+ | ... 阅读更多
100 次查看
要以所需的方式删除记录,语法如下 -delete from yourTableName where yourTableName .yourColumnName=yourValue;让我们首先创建一个表 -mysql> create table DemoTable ( StudentName varchar(100), StudentAge int ); Query OK, 0 rows affected (0.81 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Chris', 21); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('Robert', 20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('David', 22); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('Mike', 24); Query OK, 1 row ... 阅读更多
154 次查看
让我们首先创建一个表 -mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Name varchar(100), AdmissionDate date ); Query OK, 0 rows affected (0.42 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(Name, AdmissionDate) values('Chris', '2019-11-21'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Mike', '2019-03-11'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Sam', '2018-04-01'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(Name, AdmissionDate) values('Carol', '2019-05-01'); Query OK, 1 row affected (0.40 sec)显示所有记录 ... 阅读更多