Select rows from a table where row in another table with same id has a particular value in another column

后端 未结 3 2064
有刺的猬
有刺的猬 2021-02-04 08:46

In MySQL:

If we have two tables:

comments
key    |    value
=================
1      |    foo
2      |    bar
3      |    foobar
4      |    barfoo
         


        
3条回答
  •  情深已故
    2021-02-04 09:42

    I would use "INNER JOIN" in the following way:

    SELECT comments.key, comments.value FROM comments 
    INNER JOIN meta ON comments.key=meta.comment_key WHERE meta.value = 1;
    

    Cheers! ;-)

提交回复
热议问题