Reputation: 1047
I'm selecting all entries from first table which have certain category in second one. Those 2 are connected through ID, which is the same in both tables.
I'm new at UNION and JOIN, so I'm wondering if I can do this without using those? Example:
SELECT *
FROM entries,
categories
WHERE entries.id = categories.id
AND categories.category = 'default'
Upvotes: 1
Views: 57
Reputation: 823
The query is correct. Another way:
SELECT *
FROM entries
JOIN catetories ON entries.id = categories.id
WHERE categories.category = 'default';
Upvotes: 0
Reputation: 28403
Try like this
SELECT *
FROM entries INNER Join categories ON entries.id = categories.id
WHERE categories.category = 'default'
Upvotes: 1
Reputation: 322
This would work. You might as well type :
SELECT your fields FROM
entries AS E INNER JOIN categories as C USING (id)
WHERE C.category = 'default'
Upvotes: 2