How can I combinate two MySQL queries and sort them?

I have 3 tables: Parts, Store and Delivery

store.id
store.mainpnid = parts.id
store.mainpn
store.subid 
store.bnsn
store.class
store.expire
store.status
store.station

delivery.id
delivery.mainpnid
delivery.mainpn
delivery.subid
delivery.bnsn
delivery.class
delivery.expire
delivery.status
delivery.to
delivery.statindlvr

parts.metctrl
parts.description
parts.id
parts.class

I have two queries until now:

SELECT store.id, store.mainpnid, store.mainpn, store.subid, store.bnsn, store.class, store.expire, store.status, store.station, parts.metctrl, parts.description, parts.id, parts.class FROM store INNER JOIN parts ON store.mainpnid=parts.id WHERE (store.status='SA' OR store.status='US' OR store.status='QRT') AND parts.metctrl='yes' AND (parts.class = 'TR' OR parts.class = 'T') ORDER BY store.mainpn ASC, store.bnsn ASC

and

SELECT delivery.id, delivery.mainpnid, delivery.mainpn, delivery.subid, delivery.deliveryn, delivery.bnsn, delivery.class, delivery.expire, delivery.status, delivery.statindlvr, delivery.to, parts.metctrl, parts.description, parts.id, parts.class FROM delivery INNER JOIN parts ON delivery.mainpnid=parts.id WHERE (delivery.status='SA' OR delivery.status='US' OR delivery.status='QRT') AND (delivery.statindlvr = 'transit' OR delivery.statindlvr = 'pending' OR delivery.statindlvr = 'ready') AND parts.metctrl='yes' AND (parts.class = 'TR' OR parts.class = 'T') ORDER BY delivery.mainpn ASC, delivery.bnsn ASC

Until now its works ok but now I have to make a new query who content results from store and results from delivery and sort all of results mainpn ASC and bnsn ASC is there any way to do this?



from Recent Questions - Stack Overflow https://ift.tt/3rCngWQ
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation