Bring the data without repeating the id

0

I have a table named Posts table , I have a table named Users table , I have a table with the name of Relations table . Now what happens is that this relations table works as follows: The Host user goes on the site and creates a post and the freenlancer user goes there in this post where the host created and clicks on submitting a proposal. The relations table receives the id of this user, the id of the post and also the id of the owner of the post. So we created a relationship between the freenlancer and the host. My problem is that if the post receives two proposals the id of the post will suddenly. I would like to not repeat the same post, leaving the proposals of the freenlacers one below the other.

publicfunctiongetRequisicoes(){$array=array();$id_user=$_SESSION['user'];$sql="SELECT

    user.*, 

    relations.*, 

    post.*, post.url as main_image

    FROM relations 

    LEFT JOIN users as user ON user.id = relations.id_user_from

    LEFT JOIN posts_pl as post ON post.id = relations.id_post

    WHERE relations.id_post IN (post.id) AND relations.id_user_to = $id_user AND relations.status = '0' ORDER BY post.id";

    $sql = $this->db->query($sql);



    if($sql->rowCount() > 0) {

        foreach ($sql->fetchAll() as $value) {
    
asked by anonymous 25.03.2018 / 09:08

0 answers