Column in query should be selected according to value from another column Assuming I have table1 with following data:
table1
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

OR
coffee_receiver = tux, received_bag_size= m

OR
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.
Update: to make the question a little more clear:
What i want to see is the actual rows where coffee vendor and size are linked. Each coffee vendor (tux, alsa) has a bag size at a a certain point in time. This will be inserted in the table when shipment is done.
I hope this clarifies what I wanted to ask.
select t.price, t.id
from table1 t 
where (coffee_sender = tux and sent_bag_size= xl)
or (coffee_receiver = tux and received_bag_size= m)
or (coffee_sender = tux and sent_bag_size = xl AND coffee_receiver = tux and received_bag_size= m)