1、exists子查询的功能是判断返回结果中是否有数据行
SELECT DISTINCT goods_name FROM goods WHERE EXISTS (SELECT * FROM brand WHERE cat_id = goods.cat_id AND name='索尼');
2、in查询数据是否有匹配的
SELECT DISTINCT goods_name FROM goods WHERE cat_id IN(SELECT cat_id FROM brand WHERE cat_id = goods.cat_id AND name='索尼');
网友评论