これは、照会したい DB 構造の一部です。
関係は次のとおりです。
- article.art_author - user.usr_id
- article.art_id - tag_article.rel_art_id
- tag_article.rel_tag_id - tag.tag_id
可能であれば、選択したユーザーから書かれた記事 (usr_id による)、または選択されたタグ (tag_id による) を持つ記事を 1 つのクエリで選択したいと考えています。
私はこれを試しましたが、望ましい結果が得られません:
SELECT * FROM
((article JOIN user on article.art_author = user.usr_id)
JOIN
tag_article on article.art_id = tag_article.rel_art_id)
JOIN
tag on tag_article.rel_tag_id = tag.tag_id
WHERE
article.art_lang = '$cur_lang'
$sql_in
ORDER BY
article.art_date desc
LIMIT $first_record, $range