mysql里如何查询一张表里的数据比另一个数据大的数据?
发布网友
发布时间:2022-04-09 03:41
我来回答
共1个回答
热心网友
时间:2022-04-09 05:10
1、创建表
create table a (name varchar(20) not null,sex varchar(10));
create table b (name varchar(20) not null,sex varchar(10));
2、插入值
insert into a values('john','male');insert into b values('john','male');
insert into a values('kate','female');insert into b values('kate','female');
3、查询方法1
mysql> select name,sex from a where name in (select name from b where name='john');
+------+------+
| name | sex |
+------+------+
| john | male |
+------+------+
1 row in set (0.00 sec)
4、查询方法2
mysql> select a.name,a.sex from a,b where a.name=b.name and b.name='john';
+------+------+
| name | sex |
+------+------+
| john | male |
+------+------+
1 row in set (0.00 sec)