In general, there are three bases -

members - [id, cid, uid]

--------------------- 

dialogs - [id, type, name]

 --------------------- 

users - [id, nickname].

My task is to get data. First we get the dialog itself (SQL below):

 SELECT dialogs.id, dialogs.type, dialogs.name, FROM dialogs, members WHERE members.uid = "'.$my_id.'" AND dialogs.id = members.cid 

But, further, I need that if dialogs.type = 0 (private message), I have got another member - members.cid = id_of_free_dial_dialog, members.uid! = "'. $ My_id.'".

  • And what's stopping you from doing this all with the help of arrays through PHP ?? Select data in three queries and run PHP conditions. Why do you want to do this through SQL ?? - alexsis20102 pm
  • All because of the limited time and the number of dialogues. - Type Coder
  • Not very clear what is required. Try to show an example or something. There are three bases. These are tables. another member was obtained. In what form? The structure of the output set should be unchanged. - Akina
  • @ alexsis20102 what prevents you from doing this all with the help of arrays through PHP ?? So why do something in PHP that MySQL is intended for and not PHP? The fact that you know PHP better than MySQL is a damn rationale ... - Akina
  • @TypeCoder, ... WHERE (members.uid = "'. $ My_id.'" AND dialogs.id = members.cid and dialogs.type <> 0) OR (members.cid = dialogs.id and members.uid! = "$ my_id" and dialogs.type = 0) - Vfvtnjd

0