MySQL Query无法根据查询(JOIN)获取正确的记录

时间:2017-07-19 00:10:56

标签: mysql

我有两个简单的表,使用以下构建形式:

表1

id - name

表2

id - name - post_id (table1.id Fkey)

我想要的是,从TABLE 1 TABLE 1 id匹配TABLE 2 {{1} post_id获取数据}}

这很简单,但我有37条记录,而我只有13条记录。

查询:

SELECT posts.id FROM posts INNER JOIN favorites ON posts.id = favorites.post_id

执行上述查询时,结果为:

关系共享的一些记录(id = post_id),其余记录随机,post_id值为NULL

1 个答案:

答案 0 :(得分:1)

试一试并显示结果

componentDidMount