In MySQL:
If we have two tables:
comments
key | value
=================
1 | foo
2 | bar
3 | foobar
4 | barfoo
I actually wouldn't recommend a JOIN for this — or rather, I'd recommend a "semijoin", which is a relational-algebra concept not directly expressed in SQL. A semijoin is essentially a join where you want to retrieve records from only one table, but with the proviso that they have corresponding records in a different table.
In SQL notation, this concept is expressed indirectly, by using an IN clause, with a subquery:
SELECT key, value
FROM comments
WHERE key IN
( SELECT comment_key
FROM meta
WHERE value = 1
)
;
(MySQL will actually end up translating that back into a semijoin internally — essentially a sort of degenerate inner-join — but the IN
clause is the natural way to express it in raw SQL.)