找到 4379 篇文章 关于 MySQL
11K+ 次查看
要选择前 10 条记录,请在 MySQL 中使用 LIMIT。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> PageNumber text -> ); Query OK, 0 rows affected (2.50 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Page-1'); Query OK, 1 row affected (0.46 sec) mysql> insert into DemoTable values('Page-2'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Page-3'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('Page-4'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Page-5'); Query OK, ... 阅读更多
607 次查看
为此,请使用 COLUMN_NAME 并将 LIKE 设置为该特定列名。让我们在数据库中的未知表中查找特定列 -mysql> SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE, IS_NULLABLE, COLUMN_DEFAULT -> FROM INFORMATION_SCHEMA.COLUMNS -> WHERE column_name LIKE '%StudentName%' -> AND table_schema = 'web';输出这将产生以下输出 -+-------------------+-------------+-----------+-------------+----------------+ | TABLE_NAME | COLUMN_NAME | DATA_TYPE | IS_NULLABLE |COLUMN_DEFAULT | +-------------------+-------------+-----------+-------------+----------------+ | demotable215 | StudentName | varchar | YES | NULL | | demotable221 | StudentName | varchar ... 阅读更多
154 次查看
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Name text -> ); Query OK, 0 rows affected (1.31 sec)使用 insert 命令在表中插入一些记录。在这里,我们插入了一个包含特定单词“name”的名称,我们需要忽略它 -mysql> insert into DemoTable values('John 7'); Query OK, 1 row affected (0.65 sec) mysql> insert into DemoTable values('John 6'); Query OK, 1 row affected (0.42 sec) mysql> insert into DemoTable values('John 9'); Query OK, 1 row affected (0.33 sec) mysql> insert into DemoTable values('name John 3'); ... 阅读更多
226 次查看
让我们首先创建一个表 -mysql> create table DemoTable -> ( -> FirstName varchar(20), -> LastName varchar(20) -> ); Query OK, 0 rows affected (1.44 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('David', 'Miller'); Query OK, 1 row affected (0.24 sec)使用 ... 阅读更多
116 次查看
使用 COLUMN_NAME 查找数据库中哪个表包含特定列。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> CustomerId int, -> CustomerName varchar(20), -> CustomerCountryName varchar(100) -> ); Query OK, 0 rows affected (1.05 sec)以下是查找哪个表中存在特定列“'CustomerCountryName'”的查询 -mysql> select *from information_schema.columns WHERE COLUMN_NAME = 'CustomerCountryName';输出这将产生以下输出 -+---------------+--------------+--------------+---------------------+------------------+----------------+-------------+-----------+--------------------------+------------------------+-------------------+---------------+--------------------+--------------------+-----------------+--------------+------------+-------+---------------------------------+----------------+-----------------------+-------+ | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME |ORDINAL_POSITION | COLUMN_DEFAULT | IS_NULLABLE | DATA_TYPE |CHARACTER_MAXIMUM_LENGTH | CHARACTER_OCTET_LENGTH |NUMERIC_PRECISION ... 阅读更多
339 次查看
使用 LPAD() 函数在左侧填充值。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> Number int -> ); Query OK, 0 rows affected (2.26 sec插入一些记录使用 insert 命令在表中 -mysql> insert into DemoTable values(857786); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable values(89696); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(89049443); Query OK, 1 row affected (0.25 sec使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable;输出这将产生以下输出 -+----------+ | ... 阅读更多
2K+ 次查看
对完全匹配使用等于运算符 -select *from yourTableName where yourColumnName=yourValue;让我们首先创建一个表 -mysql> create table DemoTable -> ( -> FirstName varchar(100), -> LastName varchar(100) -> ); Query OK, 0 rows affected (0.70 sec插入一些记录使用 insert 命令在表中 -mysql> insert into DemoTable values('John', 'Smith'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable values('John', 'Doe'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Chris', 'Brown'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('Carol', 'Taylor'); Query OK, 1 row affected ... 阅读更多
619 次查看
是的,我们可以使用 LIKE 和 OR 运算符在 MySQL 中组合 IN 和 LIKE 运算符。让我们首先创建一个表 -mysql> create table DemoTable -> ( -> SubjectTitle text -> ); Query OK, 0 rows affected (0.68 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('Introduction To MySQL'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable values('Java in Depth'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values('Coding with Python'); Query OK, 1 row affected (0.54 sec) mysql> insert into DemoTable values('C++ in Depth'); Query ... 阅读更多
212 次查看
在 MySQL 中使用 MONTH() 方法根据月份选择日期。让我们先创建一个表 -mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(10), -> UserPostMessageDate datetime, -> UserLikes int -> ); Query OK, 0 rows affected (0.77 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('John', '2019-01-31', 4560); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('Sam', '2019-06-28', 790); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable(UserName, UserPostMessageDate, UserLikes) values('Carol', '2019-05-01', ... 阅读更多
360 次浏览
让我们先创建一个表 -mysql> create table DemoTable -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ShippingDate datetime -> ); Query OK, 0 rows affected (1.16 sec)使用 insert 命令在表中插入一些记录。考虑当前日期“2019-06-28” -mysql> insert into DemoTable(ShippingDate) values('2019-01-31'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(ShippingDate) values('2019-06-06'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(ShippingDate) values('2019-06-28'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(ShippingDate) values('2019-07-01'); Query OK, 1 row affected (0.16 sec)显示表中的所有记录 ... 阅读更多