SELECT * from tt a where exists(select 1 from tt where a.goods_id=goods_id and attribute=0) and a.attribute=1
or
not exists(select 1 from tt where a.goods_id=goods_id and attribute=1) and a.attribute=0
or
not exists(select 1 from tt where a.goods_id=goods_id and attribute=1) and a.attribute=0
解决方案 »
- MySQL WorkBench执行SQL脚本时,报错MySQL server has gone away
- AB表 求sql
- update语句执行缓慢(停止)
- 请各位大侠帮忙看一下这个Database ERROR,急~
- 求助+请教
- 请帮帮忙mysql 问题例如hot,我用什么命令取出ho后边的t?
- 版主,关于上次你寄给我的代码
- MySQL建立的数据库物理上是一个文件吗?
- 紧急求助,紧急求助!
- Navicat远程MySql数据库可以直接打开表,但是查询语句查询报错2013
- 远程或者本地连接MySQL时报错1130 host is not allowed to connect to this mysql server
- 这个查询该如何写
SELECT *,IF(attribute = 'A属性',attribute,attribute) FROM tb
GROUP BY goods_id
select *
from 这样一张表
order by attribute
) t
group by goods_id