Reputation: 875
What i need is cartesian product in WHERE clause:
for example i have cities London, Barcelona, Milan, Paris in one variable, and Berlin in other variable.. i need all combinations in where clause (london-berlin, barcelona-berlin, milan-berlin, paris-berlin).
SELECT *
FROM flight
WHERE flight.from = (London, Barcelona, Milan, Paris) AND flight.to = 'Berlin'
Upvotes: 0
Views: 350
Reputation: 180947
If flight.from is a char/varchar, try;
SELECT * FROM flight
WHERE `from` IN ('London', 'Barcelona', 'Milan', 'Paris') AND `to`='Berlin';
Upvotes: 1
Reputation: 360742
Try:
WHERE flight.from IN ('London', 'Barecelona', 'Milan', 'Paris') AND (flight.to = 'Berlin')
Upvotes: 2