找到 4379 篇文章 关于 MySQL
743 次浏览
让我们首先创建一个表 -mysql> create table DemoTable741 (Number int); Query OK, 0 rows affected (0.61 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable741 values(70); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable741 values(55); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable741 values(89); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable741 values(79); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable741 values(34); Query OK, 1 row affected (0.17 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable741;这将... 阅读更多
711 次浏览
使用 LIKE 查找包含双引号的记录。以下是语法 -select *from yourTableName where yourColumnName LIKE '%"%';让我们首先创建一个表 -mysql> create table DemoTable740 (Value varchar(100)); Query OK, 0 rows affected (0.49 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable740 values("\""); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable740 values("\"John"); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable740 values("Sam"); Query OK, 1 row affected (0.12 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable740;这将产生以下输出 -+-------+ | ... 阅读更多
178 次浏览
让我们首先创建一个表 -mysql> create table DemoTable739 (Price int); Query OK, 0 rows affected (0.65 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable739 values(100); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable739 values(50); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable739 values(1200); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable739 values(500); Query OK, 1 row affected (0.37 sec) mysql> insert into DemoTable739 values(800); Query OK, 1 row affected (0.20 sec)使用 select 语句显示表中的所有记录 -mysql> select *from DemoTable739;这将... 阅读更多
89 次浏览
假设表中有一些列,一列用于图像路径,另一列用于点赞数。但是,第一列是自增 ID,如下所示 -mysql> create table DemoTable( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ImagePath varchar(100), UpvoteValue int ); Query OK, 0 rows affected (0.72 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable(ImagePath, UpvoteValue) values('Image1.jpeg', 90); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable(ImagePath, UpvoteValue) values('Image2.jpeg', 10); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable(ImagePath, UpvoteValue) values('Image3.jpeg', 120); Query OK, 1 ... 阅读更多
439 次浏览
要查找包含 a-z、A-Z 和 0-9 的字符串,请使用 BINARY REGEXP 以及 AND 运算符。让我们首先创建一个表 -mysql> create table DemoTable738 (UserId varchar(100)); Query OK, 0 rows affected (0.81 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable738 values('John'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable738 values('sAm456'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable738 values('98Carol'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable738 values('67david'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable738 values('69MIKE'); Query OK, 1 row affected (0.18 ... 阅读更多
665 次浏览
要在 MySQL 中创建空视图,以下是语法 -create or replace view yourViewName as select yourValue AS yourColumnName, yourValue AS yourColumnName2, . . N from dual where false;让我们在 MySQL 中实现上述语法以创建空视图 -mysql> create or replace view empty_view as select "John Smith" AS ClientName, "US" AS ClientCountryName, false AS isMarried from dual where false; Query OK, 0 rows affected (0.20 sec)让我们检查视图的描述 -mysql> desc empty_view;这将产生以下输出 -+-------------------+-------------+------+-----+---------+-------+ | Field ... 阅读更多
3K+ 次浏览
使用 DEFAULT CURRENT_TIMESTAMP 和 ON UPDATE CURRENT_TIMESTAMP,列将使用当前时间戳作为其默认值,并自动更新为当前时间戳。让我们看一个例子并创建一个表 -mysql> create table DemoTable737 ( StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentName varchar(100), StudentAdmissiondate datetime ); Query OK, 0 rows affected (0.68 sec)以下是 MySQL 中 CURRENT_TIMESTAMP 和 ON UPDATE CURRENT_TIMESTAMP 的查询 -mysql> alter table DemoTable737 modify column StudentAdmissiondate timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; Query OK, 0 rows affected (2.20 sec) Records: 0 Duplicates: 0 Warnings: 0让我们... 阅读更多
1K+ 次浏览
要更新所有条目,同时忽略单个值,您需要使用 IF()。让我们首先创建一个表 -mysql> create table DemoTable736 ( CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY, CustomerName varchar(100), isMarried boolean ); Query OK, 0 rows affected (0.53 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable736(CustomerName, isMarried) values('Chris', 0); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable736(CustomerName, isMarried) values('Robert', 0); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable736(CustomerName, isMarried) values('David', 0); Query OK, 1 row affected (0.24 sec) mysql> insert into ... 阅读更多
49 次浏览
让我们首先创建一个表 -mysql> create table DemoTable(EmployeeCode varchar(100)); Query OK, 0 rows affected (0.56 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable values('EMPLOYEE:100 John Smith'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('EMPLOYEE:16537 Chris Brown'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable values('EMPLOYEE:100 David Miller'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('EMPLOYEE:100 23432 David Miller'); Query OK, 1 row affected (0.20 sec)使用 select 语句显示表中的所有记录 -mysql>; select *from DemoTable;这将产生以下输出 ... 阅读更多
4K+ 次浏览
要在 MySQL 中合并行,请使用 GROUP_CONCAT()。让我们首先创建一个表 -mysql> create table DemoTable734 ( Id int, Name varchar(100) ); Query OK, 0 rows affected (0.73 sec)使用 insert 命令在表中插入一些记录 -mysql> insert into DemoTable734 values(101, 'John'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable734 values(102, 'John'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable734 values(103, 'Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable734 values(104, 'Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable734 values(104, 'Chris'); Query OK, 1 row affected ... 阅读更多