Assuming I have table1 with following data:
id| coffee_sender | coffee_receiver | received_bag_size | sent_bag_size| price | 21 tux -1 m -1 45 22 alsa -1 -1 xl 36 23 -1 tux l -1 51
And I use the following query:
select t1.* from ( select t.price, t.id from table1 t where coffee_sender in (tux, alsa) or coffee_receiver in (tux, alsa) and received_bag_size in (m, xl) or sent_bag_size in (m, xl)) t1
What i want is to only fetch the rows that have coffee_sender/coffee_receiver AND sent_bag_size/received_bag_size filled with a value (rows that match the following conditions):
coffee_sender = tux, sent_bag_size= xl
coffee_receiver = tux, received_bag_size= m
coffee_sender = tux, sent_bag_size = xl AND coffee_receiver = tux, received_bag_size= m
So id = 21 would be excluded from the example table1.
How can i update the above query for this ? Thank you in advance.