Bir üç yol mysql tabloları ve php katılmak?

0 Cevap php

user_table

 user_id | username
       1 | solomon
       2 | muna

mesaj tablo

id    user_id| message
 1       1   | this is my first message
 2       1   | this is my seocnd message
 3       2   | this is muna messgae    

ilişki tablo

  leader | follower
       1 | 2
         |    

ben ne yapmak istiyorum, üç tablo (takipçileri tabloda gösterildiği gibi) şu anda muna Süleyman'ı takip Muna arkadaşı mesajları ortaya çıkarmak için join

bu yüzden ekran mona ana sayfasında bu gibi olmak istiyorum

Solomon "this is my my first message
----------------------------------
solomon "this is my second message"

P.S. bu ben sadece sorunu yaklaşım nasıl görmek istedim, sadece bir örnek veritabanı ve bu şimdiye kadar çalışmışlardır budur!

 select username, message, leader
    from user, message, relationship where user.user_id =notes.user_id 
and user.user_id = relationship.leader and where user_id = $_SESSION['user_id']

* Session id 2 user_id olan Muna olduğu

0 Cevap