I have two simple tables, with the following build form:
TABLE 1
id - name
TABLE 2
id - name - post_id (table1.id Fkey)
What I want is, to get the data from the TABLE 1
where the TABLE 1
's id
matches TABLE 2
's post_id
It's pretty easy, but I have 37 records and I'm getting only 13 records.
Query:
SELECT posts.id FROM posts INNER JOIN favorites ON posts.id = favorites.post_id
When the above query is executed, the result is:
Some records that are shared by the relation (id = post_id), and the rest records are random with post_id
value as NULL