It is necessary that this request be executed:

SELECT name_EN AS AL, name_RU AS AL, name_TR AS AL FROM tbl WHERE name_EN LIKE '%param%' OR name_TR LIKE '%param%' OR name_RU LIKE '%param%'; 

Please pay attention to the alias: AS AL for each field in the SELECT.

  • 3
    And which column do you hope to turn to after this name AL ? - Nofate
  • Then I ask for help, how to avoid it. Those. you need to search for LIKE by fields - but return the name of one field (the same name). - Jony
  • 2
    In the question, give an example of the table and what the query should return. - Ale_x
  • A table of IDs, and only those fields that are in the query. - Jony
  • five
    Read on UNION: SELECT name_EN AS AL From Table Where name_EN LIKE '% param%' UNION SELECT name_TR AS AL From Table Where name_TR LIKE '% param%' UNION SELECT name_RU AS AL From Table Where name_RU LIKE '% param%' - alexlz 5:02 pm

1 answer 1

You cannot assign the same alias to several columns in the resulting table with the AS construct. However, you can form one column that will accept the value found.

When forming the query, it should be remembered that the LIKE construct is not necessarily applied only in the WHERE condition, you can use it after the SELECT . By applying multiple CASE choices, you can select the column that was detected and assign an alias to it using the AS construct.

Thus, your request can be rewritten as

 SELECT CASE WHEN name_EN LIKE '%param%' THEN name_EN WHEN name_RU LIKE '%param%' THEN name_RU WHEN name_TR LIKE '%param%' THEN name_TR END AS AL FROM tbl WHERE name_EN LIKE '%param%' OR name_TR LIKE '%param%' OR name_RU LIKE '%param%'