I have table journal
containing these columns:
| id | journalName | issn |
I need to: filter the table based on the concatenation result of journalName & issn (using LIKE syntax) - and display only the journalName and issn (concatenation result are not selected). Concatenation result need to filtered against several LIKE criteria, so it would be reasonable to put them inside a variable.
This is WHERE approach (concat is called repeatedly):
SELECT journalName, issn
FROM `journal`
WHERE
CONCAT_WS(' ',journalName,issn) LIKE '%375%' AND
CONCAT_WS(' ',journalName,issn) LIKE '%res%'
My current approach (use variable but two SELECT statements):
SELECT journalName, issn FROM
(
SELECT journalName, issn, CONCAT_WS(' ',journalName,issn) AS searchable
FROM `journal`
HAVING
searchable LIKE '%375%' AND
searchable LIKE '%res%'
ORDER BY searchable DESC
) t
Is there any other way to do it using only one SELECT statement while having concat result stored in a variable simultaneously?
n.b.: Adding column is not an option. I have read this and this