I’m struggling with SQL today. I’ve got a lookup table of a lookup table and can’t work out the SQL to do a search. As an example, consider the following:
Table 1 – books:
fields: book_id, price, title, author
example:
1, 2.99, ‘Life’, ‘A. Slug’
2, 4.99, ‘The Universe’, ‘A. Planet’
Table 2 – book_fields:
fields: field_id, field_name
example:
1, ‘cover_colour’
2, ‘cover_type’
Table 3 – book_field_lookup:
fields: book_id, field_id, field_value
1, 1, ‘blue’
1, 2, ‘hardback’
2, 1, ‘blue’
2, 2, ‘softback’
How do I find all hardback books that are blue?