Getting friend list from MySQL using PHP -


i have tables in mysql database, users , friends. have structure:

users table:

friends table (two users friends if exists 2 rows in image):

enter image description here

i want create mysql query in php select nombre (name) of users friends. read have use operator left join did not succeed.

thank you!

try using inner join instead. try below query -

select users.nombre users inner join friends on  (users.id = friends.usuari_o or users.id = friends.usuari_t) (friends.usuari_o = $id or friends.usuari_t = $id); 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -