I would like to query only the data I want from my database using a join. Yet, I am having trouble getting my query to work.
Here is my code. Take a look,
<?php
$user_id= $_COOKIE['user_id'];
$dbc= mysqli_connect('localhost', 'root', '', 'beta');
$query=" SELECT * FROM posts LEFT JOIN relationships ON (posts.user_id=
relationship.user_2 AND relationships.user_1 = $user_id AND relationship.status = 4 OR
3 OR 1)";
$result= mysqli_query($dbc, $query);
echo mysqli_num_rows($result);
?>
I am only trying to see if the query works at this point, by seeing if it returns any rows. But It won’t work. What could I be doing wrong?
You’re mixing “relationships” and “relationship” in your query, maybe stick to what the name of the table is?