There is a table, in it - many fields.
I want to select all the fields where the поле_имени matches my text, in the same query I want to pull out all the fields where the поле_описания matches the same text.
How to do it? Or at least show in which direction to dig =)
Requests themselves:
SELECT * FROM table_goods WHERE name LIKE '%искомый_текст%' SELECT * FROM table_goods WHERE descr LIKE '%искомый_текст%' I just need the result of these queries to be common, but that the 1st half of the result was with the match in the name, and the 2nd half with the match in the description.
For example,
id "1", name "мандарин", descr "с марковкой хорошо" id "2", name "марковка", descr "описание" id "3", name "огурцы-1", descr "сочетается с молоком" id "4", name "помидоры", descr "с мясом хорошо сочетается" id "5", name "марковный_сок", descr "описание" We execute the query LIKE '% Mark%' first by name then by description and as a result we want to get:
id "2", name "марковка", descr "описание" id "5", name "марковный_сок", descr "описание" id "1", name "мандарин", descr "с марковкой хорошо" First displayed the results by name, then by description.
Help make one request, please.
UNIONoperator. - YaantLIKE %...%overhead sorting can be almost neglected. :) And if non-critical duplication of records that have the search text at the same time in the title and in the description, then you can useUNION ALL- Yaant