There is a description table:

 id title text text_ru 

And the description_title table:

 id text text_ru 

It is necessary to combine the data of these tables in the field title -> id, now I wrote such a query:

 SELECT d.*, dt.* FROM description d LEFT JOIN description_title dt ON (d.title = dt.id) WHERE d.id = 1 

Now it turns out that the fields with the same name in the tables interrupt each other, is it possible to return them in such a way that this does not happen, for example, add some prefix to the first table and the second as a result?

PS The option of listing the fields of each table and specifying prefixes will not work, because new fields will be added to these tables, for example text_ua , multilanguage. Those. all fields in the first table and all fields in the second table must be returned.

PSS Now the result is: id - title - text - text_ru - id - text - text_ru . And you need to get something like this: table1_id - table1_title - table1_text - table1_text_ru - table2_id - table2_text - table2_text_ru .

  • Why, I'm trying to write a universal query, the results of which will be processed in php? - Shillkas pm
  • So that when adding new fields to the table, the sql query itself would not need to be modified. - Shillkas
  • "So that when adding new fields to the table, the sql query itself would not need to be changed" will not work. And how will you track new fields in php? - Dmitry Kozlov
  • one
    One of the basic rules to never use * in a SELECT query is Anton Shchyrov
  • I understand what you mean. But I'm afraid mysql is not able to do this automatically. You will have to prescribe aliases yourself - Roman Danilov

0