Answer the question
In order to leave comments, you need to log in
How to correctly compose a SELECT from multiple tables?
Good afternoon, help or point in the right direction with a request like this:
SELECT `frk_item` . * , `frk_itemcomment` . *,
CASE
WHEN authorId=1 THEN 'Коля'
END as idname,
CASE
WHEN projectId=12 THEN 'TEST'
END AS grname
FROM frk_item JOIN `frk_itemcomment`
USING ( `itemId` )
WHERE
frk_item.itemId in
(SELECT itemId FROM frk_item WHERE `title` LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%'
OR `description` LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%')
OR frk_itemcomment.itemId in
(SELECT itemId FROM frk_itemcomment WHERE `body` LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%')
ORDER BY postDate DESC
Answer the question
In order to leave comments, you need to log in
It is not clear why, but the results are different if you remove the ORDER BY.
Your WHERE is identical to the following:
WHERE
frk_item.`title` LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%'
OR frk_item.`description` LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%'
OR frk_itemcomment.body LIKE '%Скрипт рекурсивного мониторинга старых файлов в папках cache%'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question