用户表 table_1
id name sex status1 渣渣徽 1 1 2 谷田乐 1 1
用户角色等级表 table_2
UID 为表一关联字段 id uid level_name level_id1 1 青铜 1 1 1 白银 21 2 白银 21 2 黄金 3
查询所有青铜等级的用户,这样单条件没问题
SQL
select * from table_1 RIGHT JOIN table_2 ON table_1.id = table_2.uidwhere table_1.status = 1 AND table_2.level_id = 1 group by table_1.id
但是如何查询同时拥有青铜与白银的角色呢?
如下查询条件是不行的
select * from table_1 RIGHT JOIN table_2 ON table_1.id = table_2.uidwhere table_1.status = 1 AND table_2.level_id = 1 AND table_2.level_id = 2
此条件该如何查询?
翻翻过去那场雪
相关分类