找到关于 MySQL 的 4379 篇文章
634 次浏览
让我们首先创建一个表 −mysql> create table DemoTable1368 -> ( -> ClientId int, -> ClientName varchar(20) -> ); Query OK, 0 rows affected (0.58 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1368 values(101, 'Adam'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1368 values(102, 'Bob'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1368 values(103, 'John'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1368 values(104, 'Sam'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1368 values(105, ... 阅读更多
637 次浏览
要显示没有任何行和列,请使用 SELECT NULL 和 FALSE,如下面的语法所示 −select null from yourTableName where false;让我们首先创建一个表 −mysql> create table DemoTable1367 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.55 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1367(FirstName) values('Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1367(FirstName) values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1367(FirstName) values('Bob'); ... 阅读更多
591 次浏览
为此,请使用 SUBSTR(),如下面的语法所示 −select * from yourTableName where substr(yourColumnName, 2, 1 ) = ' ';让我们首先创建一个表 −mysql> create table DemoTable1365 -> ( -> Value varchar(20) -> ); Query OK, 0 rows affected (0.66 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1365 values('9756757474'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable1365 values('3 45322333'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable1365 values('8974646363'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable1365 values('9 ... 阅读更多
142 次浏览
让我们首先创建一个表。在这里,我们将日期设置为 VARCHAR −mysql> create table DemoTable1364 -> ( -> ShippingDate varchar(100) -> ); Query OK, 0 rows affected (0.87 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1364 values('01-09-2019 12:34:55'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1364 values('01-07-2018 17:10:00'); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable1364 values('24-09-2019 10:31:22'); Query OK, 1 row affected (0.24 sec) mysql> insert into DemoTable1364 values('20-09-2018 13:00:00'); Query OK, 1 row affected (0.13 sec) 显示所有记录 ... 阅读更多
139 次浏览
让我们首先创建一个表 −mysql> create table DemoTable1363 -> ( -> StudentId varchar(20) -> ); Query OK, 0 rows affected (0.57 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1363 values('901'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1363 values('702'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1363 values('901_John_Doe'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1363 values('1001_Carol_Taylor'); Query OK, 1 row affected (0.26 sec) 使用 select 语句显示表中的所有记录 −mysql> select * from DemoTable1363;这将 ... 阅读更多
211 次浏览
为此,语法如下所示 −revoke show databases on *.* from 'yourUserName'@'yourHostName';让我们显示所有用户名及其主机名 −mysql> select user, host from MySQL.user;这将产生以下输出 −+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | Charlie | % | | Robert | % | | User2 | % ... 阅读更多
605 次浏览
在存储过程中使用 MySQL DECLARE 来声明变量 −DECLARE anyVariableName int DEFAULT anyValue;让我们实现上述语法来在存储过程中创建变量 −mysql> DELIMITER // mysql> CREATE PROCEDURE variable_Demo() -> BEGIN -> DECLARE lastInsertedId int DEFAULT -1; -> select lastInsertedId; -> set @providedLastId=10001; -> select @providedLastId; -> END -> // Query OK, 0 rows affected (0.32 sec) mysql> DELIMITER ;现在您可以使用 CALL 命令调用上述存储过程 −mysql> call variable_Demo();这将产生以下输出 −+----------------+ | lastInsertedId | ... 阅读更多
171 次浏览
让我们首先创建一个表 −mysql> create table DemoTable1362 -> ( -> ClientId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> ClientName varchar(40) -> ); Query OK, 0 rows affected (0.67 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1362(ClientName) values('Chris'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1362(ClientName) values(' '); Query OK, 1 row affected (0.08 sec) mysql> insert into DemoTable1362(ClientName) values('Bob'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable1362(ClientName) values(' '); Query OK, 1 row affected (0.12 sec) mysql> insert ... 阅读更多
617 次浏览
要查找两个特定的列名,请使用 information_schema.columns。在这里,我使用 Id 代替 columnA,使用 Name 代替 columnB −mysql> select table_name as TableNameFromWebDatabase -> from information_schema.columns -> where column_name IN ('Id', 'Name') -> group by table_name -> having count(*) = 3;这将产生以下输出。以下是包含列 Id 和 Name 的表 −+--------------------------+ | TableNameFromWebDatabase | +--------------------------+ | student | | distinctdemo | | secondtable | | groupconcatenatedemo ... 阅读更多
251 次浏览
要删除具有特定域的 URL,请使用 DELETE 和 LIKE 子句。让我们首先创建一个表 −mysql> create table DemoTable1361 -> ( -> URL text -> ) ; Query OK, 0 rows affected (0.58 sec) 使用 insert 命令在表中插入一些记录 −mysql> insert into DemoTable1361 values('Https://www.google.com//?id=1'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1361 values('Https://www.facebook.com//?id=2&name=John'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable1361 values('Https://www.yahoo.com//?id=3'); Query OK, 1 row affected (0.31 sec) mysql> insert into DemoTable1361 values('Https://www.google.com//?id=1'); Query OK, 1 row affected (0.16 sec) 显示所有记录 ... 阅读更多