简体   繁体   中英

Sql query to Compare same fields of different rows in the same table in mysql

I'm trying to get the records from "tbl_gig" table while comparing different rows in it. 在此输入图像描述 I tried this but no luck:

SELECT * FROM tbl_gig as t2 INNER JOIN tbl_gig as t3 
WHERE t2.gig_city=t3.gig_city 
  AND t2.artist_id=t3.artist_id 
  AND t2.partner_id < t3.partner_id 
GROUP BY t2.gig_eventDate;

Expected output :

gig_id   gig_artist_id  gig_partner_id

1        1                1
2/3      1                1/2
4        1                1

Please help on this.

SELECT 
   GROUP_CONCAT(gig_id SEPARATOR '/') as gig_id,
   artist_id ,
   GROUP_CONCAT(partner_id SEPARATOR '/') as partner_id
   FROM tbl_gig 
   GROUP BY artist_id 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM