Mysql union give priority to record from one of the select queries in case of duplicates?

Just add a literal value to each one and then order by it SELECT * FROM ((SELECT deal. Dealid, deal. Titleen, deal.

Capnum, deal. Imagelink, SUM(buy. Quantity) AS quantity, 'A' sortby FROM buy, deal WHERE buy.

Dealid = deal. Dealid AND buy. Isfinalbuy = '1' GROUP BY buy.

Dealid HAVING quantity = deal. Capnum) UNION (SELECT deal. Dealid, deal.

Titleen, deal. Capnum, deal. Imagelink, NULL AS quantity, 'B' sortby FROM deal WHERE deal.Enddate.

Just add a literal value to each one and then order by it. SELECT * FROM ((SELECT deal. Dealid, deal.

Titleen, deal. Capnum, deal. Imagelink, SUM(buy.

Quantity) AS quantity, 'A' sortby FROM buy, deal WHERE buy. Dealid = deal. Dealid AND buy.

Isfinalbuy = '1' GROUP BY buy. Dealid HAVING quantity = deal. Capnum) UNION (SELECT deal.

Dealid, deal. Titleen, deal. Capnum, deal.

Imagelink, NULL AS quantity, 'B' sortby FROM deal WHERE deal. Enddate.

Thank you it is working now. – SilentCoder Oct 19 at 16:27 Btw: there is no need to wrap each SELECT of the union in brackets – a_horse_with_no_name Oct 19 at 17:16.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions