Mysql two tables using 'in'
Posted on 2013-10-04
I am having trouble visualizing this query:
I have a table that stores order details:
order_id code value
149396 total 18.6840
149396 sub_total 10.6200
I pull the data out for reporting purposes like:
select code,value from order_total where order_total.order_id = '149396' and code in ('sub_total','total')
This shows returns
All good, but a want to add a second table on the order_id that contains a payment method 'payment_code' and display the result like:
This is my current query but result shows in new column, I can't see how to get the second table as an 'in'
INNER JOIN `order` as order1 ON order1.order_id = order_total.order_id
where order_total.order_id = '153981' and code in ('sub_total','total')