I have the following two tables.
- nodes
- attributes
nodes
id title
1 test
2 test2
attributes
id node_id title value
1 1 featured 1
2 1 age 13
3 2 featured 2
I would like query nodes with attribute title ‘featured’ along with its all attributes.
I tried to join, but I don’t know how to query other attributes at the same time.
Is it possible to make a single query to do this?
You could use a subquery to get the ID’s of all nodes with the attribute ‘featured’. The outer query would be the
JOINto get the rest of the attributes.Like: