SELECT DISTINCT
a.fullname,
a.belong_user_id AS belong_id,
a.store_type
FROM
c_store_tbl a
JOIN c_store_tbl b ON a.store_type != b.store_type
WHERE
a.belong_user_id = b.belong_user_id
ORDER BY
a.belong_user_id,
a.store_type
SELECT DISTINCT
a.fullname,
a.belong_user_id AS belong_id,
a.store_type
FROM
c_store_tbl a
JOIN c_store_tbl b ON a.store_type != b.store_type
WHERE
a.belong_user_id = b.belong_user_id
ORDER BY
a.belong_user_id,
a.store_type
转载于:https://www.cnblogs.com/xlsxls/p/9520433.html