mysql - Subquery vs join -
select id posts subject_id = 1 or subject_id in ( select related_subject_id relatedsubjects parent_subject_id = 1);
trying select posts current subject sub-subjects stored in lookup table. above query works, wondering how accomplish same thing join
select distinct id posts p left join relatedsubjects r on p.subject_id = r.related_subject_id , r.parent_subject_id = 1 p.subject_id = 1 or r.related_subject_id not null
Comments
Post a Comment