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同步中的问题
- 收藏 中文用户名登陆有误,字符编码问题,怎么弄?
- 请教一个关于mysql日志的小问题
- Mysql 乱码,急救
- mysql建表把时间串赋值为now()的时候出错。
- 【请教】Mysql数据库安全问题一问
- /usr/libexec/mysqld: Table 'mysql.host' doesn't exist
- 我并没有改密码,怎么进不去了mysql
- MYSQL语句错误求指导
- 从MySQL中读出一张图片被无限放大!
- 远程或者本地连接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