I have these two tables:
actions
action_data
action_data belongs to actions and has the columns: action_id, name, value
The contents may look like this:
Actions:
id |
-----
178|
179|
action_data:
action_id | name | value
-------------------------------------
178 | planet | earth
178 | object | spaceship_a
179 | planet | earth
179 | object | building
Now I want to select the action, which has planet = earth and object = spaceship_a in action_data.
How can I achieve this with SQL? If you had only one condition it would work like this:
SELECT DISTINCT
actions.*
FROM
actions
INNER JOIN
action_data ON actions.id = action_data.action_id
WHERE
(action_data.name = 'planet' AND action_data.value = 'earth');
But I need two or more conditions from action_data.
Any ideas?