join - MYSQL Joining 3 tables with one being a link table -
you think easy find after lot of searching cannot find example fits, because im using wrong keywords searching. realize pretty basic have tried many variations , cant , lot of examples im seeing have a.tablename , b.tablename makes confusing, while intent read on mysql further know basics im looking out of hole can current code working now.
here sql join miserably fails:
select faq.faq_title faq, category inner join faq_link_category on faq_link_category.category_id = category.category_id faq_link_category.category_id =6 basically have 3 tables
faq table --------- faq_id faq_title category table --------- category_id category_name faq_link_category --------- faq_id category_id whats happening each faq can have more 1 category associated set way search on lines of:
show me faq titles category = 6
but im getting 500 results instead of 4 or 5.
in short im arriving on page index.php?=6
so want find faqs category category_id = x happens 6 in example.
what need outer join:
select faq_title faq f join faq_link_category flc on f.faq_id = flc.faq_id join category c on flc.category_id = c.category_id flc.category_id = 6
Comments
Post a Comment