sql >> Database >  >> RDS >> Mysql

Resultaten van unie combineren in één rij wanneer sommige kolommen verschillende waarden hebben

Verwijder tracking_id uit de subquery's en gebruik union :

(select trv.requested_date, trv.requested_status
from  tbl_trackvalue as trv, tbl_tracking as t , tbl_offers as off , tblusers as usr
where t.id=trv.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and trv.payment_status='pending' and trv.requested_status='declined'  group by trv.tr_user_id, trv.requested_date order by trv.requested_date asc )
union
(select mlc.requested_date, mlc.requested_status
from  tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr, tbl_mailchimp_trackvalue as mlc
where trv.tracking_id=mlc.tracking_id  and off.id=t.offer_id and  usr.id=trv.tr_user_id and usr.id='1454' 
and mlc.payment_status='pending' and mlc.requested_status='declined'  group by trv.tr_user_id, mlc.requested_date order by mlc.requested_date asc ) 


  1. Wijzig een MySQL-kolom in AUTO_INCREMENT

  2. SQLEXCEPTION-bericht ophalen in procedures MySQL 5.5.x

  3. Hoe de grootste waarden uit een database halen en weergeven?

  4. Geen liblwgeom bij gebruik van postgresql84 en postgis op Snow Leopard met MacPorts