找到 4379 篇文章 关于 MySQL
155 次浏览
是的,我们可以这样做。语法如下:语法 1:select * from yourTableName1, yourTableName2; 语法 2:select * from yourTableName1 cross join yourTableName2;以上两种语法产生相同的结果。让我们首先创建一个表:mysql> create table DemoTable1882 ( Id int ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1882 values(10); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1882 values(20); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1882 values(30); Query OK, 1 row affected (0.00 sec)显示所有记录 ... 阅读更多
79 次浏览
要对数字字符串使用比较运算符,请使用 substring() 方法。让我们首先创建一个表:mysql> create table DemoTable1881 ( UserId int, UserEducationGap varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1881 values(101, '5-9'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1881 values(102, '2-4'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1881 values(103, '4-8'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1881 values(104, '7-12'); Query OK, 1 row affected (0.00 sec)显示所有记录 ... 阅读更多
3K+ 次浏览
为此,请使用 INSERT INTO SELECT 语句。让我们首先创建一个表:mysql> create table DemoTable1879 ( Id int, Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1879 values(101, 'Chris Brown'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1879 values(102, 'David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1879 values(103, 'Adam Smith'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable1879;这将产生 ... 阅读更多
160 次浏览
使用 IFNULL() 查找并为 NULL 值放置特定值。让我们首先创建一个表:mysql> create table DemoTable1878 ( FirstName varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1878 values('Chris'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1878 values(NULL); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1878 values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1878 values(NULL); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录 ... 阅读更多
5K+ 次浏览
让我们首先创建一个表:mysql> create table DemoTable1877 ( DueDate datetime ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1877 values('2019-12-10'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1877 values('2019-12-05'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1877 values('2019-12-07'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1877 values('2019-12-09'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable1877;这将 ... 阅读更多
519 次浏览
让我们首先创建一个表:mysql> create table DemoTable1875 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Class varchar(20), Amount int ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1875(Class, Amount) values('X', 750); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1875(Class, Amount) values('X', 140); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1875(Class, Amount) values('X', 450); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1875(Class, Amount) values('Y', 6780); Query OK, 1 row affected (0.00 ... 阅读更多
1K+ 次浏览
为此,请使用带有 UPDATE 命令的 CASE 语句。让我们首先创建一个表:mysql> create table DemoTable1874 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Amount varchar(100) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1874(Amount) values('3450'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('190'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('7600'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1874(Amount) values('4500'); Query OK, 1 row affected (0.00 sec)显示所有记录 ... 阅读更多
347 次浏览
要更新单个列,请使用 UPDATE 和 SET,如下面的语法所示:update yourTableName set yourColumnName=yourValue;让我们首先创建一个表:mysql> create table DemoTable1873 ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, FirstName varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1873(FirstName) values('John'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1873(FirstName) values('Adam'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1873(FirstName) values('David'); Query OK, 1 row affected (0.00 sec) mysql> insert into ... 阅读更多
244 次浏览
为此,请使用 SUBSTRING()。让我们首先创建一个表:mysql> create table DemoTable1872 ( Name varchar(20) ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1872 values('John Doe'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1872 values('Adam Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1872 values('Mitchell Johnson'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable1872;这将产生以下输出:+------------------+ | Name ... 阅读更多
205 次浏览
让我们首先创建一个表:mysql> create table DemoTable1871 ( ArrivalDate datetime ); Query OK, 0 rows affected (0.00 sec)使用 insert 命令在表中插入一些记录:mysql> insert into DemoTable1871 values('2019-12-19 7:45:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1871 values('2018-11-10 12:00:00'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1871 values('2019-01-31'); Query OK, 1 row affected (0.00 sec)使用 select 语句显示表中的所有记录:mysql> select * from DemoTable1871; 这将产生以下输出:+---------------------+ | ArrivalDate | ... 阅读更多