mysql query to display messages with sender and reciever -
my messaging schema
user id name
message id messagetitle sender_id receiver_id
i want display messagetitle
sender , receivers name
for example mysql query should display :
+--------------+------------+--------------+ | messagetitle | sendername | recievername | +--------------+------------+--------------+ | important | raj | vijay | | solution | vijay | raj | +--------------+------------+--------------+
try following sql solution:
select m.messagetitle messagetitle ,u1.name sendername ,u2.name recievername message m inner join user u1 on u1.id = m.sender_id inner join user u2 on u2.id = m.receiver_id
Comments
Post a Comment