Tuesday, 15 September 2015

mysql - multiple where clause in sql -


I do not know if this is possible, but I will try it.

I have 3 tables:

First table: (sender_id and receiver_id is a foreign key that is referenced for login portal)

  Message sender_id | Receiver_id | Message 3 1 | ...  

The second table: (req_id is a foreign key referenced request table)

  Login Portrait Login PORTAL_id | Username Req_id 1 | Administrator | 1 3 | User | 2  

Third table:

  request req_id | First name Surname 1 | John | Do 2 Jane | I  

problem:

whenever I used this query:

  "SELECT id, message_sender_id, message_title, message_a, sent_date, message_status, user name, first name, message name included in m inner login portal inner join request RM on M.am.asej_resivr_aidi = Elklagin Porttal_aidi and Elkrek_aidi = Arkrek_aidi WHERE m.message_receiver_id = ( Login portal from the logged in portal WHERE Username = ''. $ _SESSION ['user'] "')".  

What is the receiver username and receiver first name and surname? What do I want that I have a receiver username but the first name and surname of SENDER. Is it possible?

I think you need to add a message_id field, then find from two subqueries and something along these lines receivers information on their new Sndesh_aidi ... the trials Not done

  SELECT query1.username, query2.firs tname, query2.surname Select FROM (select user name, Queryl, as Message_id Loginportal message where loginPortal_id = receiver_id) (first name, last name, Message_id request, Loginport message where requested .req_id = loginportal_req.id And loginportal.loginPortal_id = messages.sender_id) query2 where query1. Message_id = query2.message_id;  

No comments:

Post a Comment