mysql - Filter register from two tables -
i new here , php/mysql programming. need next consult in database.
i have 2 tables:
-the first of relations between users friends have value "2" columns like:
id | username1 | username2 | relation
-the seconds messages post users columns like:
id | username | message
the id "primary key" auto increment property. (in both)
i want show message of friends of 1 user order of post (most first)
so need select max value id user1 , user2 friends, need select max value of "messages table" , check if friends in "relations table"
i know next not syntax need this:
select message message_table max(id) , ( relations ( ( user1="randomuser" or user2="randomuser") , relation="2") ) order id desc
i know wrong... need 2 filters show friend message in posting order.. how can show register 1 table 1 condition in table , second condition in other table.
pd:sorry bad english
edit: example:
id | username1 | username2 | relation 1 randomuser1 randomuser2 2 2 randomuser1 randomuser3 0 3 randomuser1 randomuser5 2 id | username | message 1 randomuser1 hi random message? 2 randomuser2 don"t message 3 randomuser5 sure, bad message
so want show message of friends of randomuser1 order of posting
first user"s friends of randomuser1 randomuser2 , randomuser5 (the "2" mean friends) want show messages of friends order of posting (by id order of second table (message_table))
so need output like:
id | username | message 3 randomuser5 sure, bad message 2 randomuser2 don"t message
that output need when choose messages of friends of user randomuser1
Comments
Post a Comment