I developed a tag system with PHP and MySql. Websites (table 1) are associated to many tags (table 2) in a third table (table 3):
table1:
! ----- ! -----------------!
! t1_id ! t1_libelle !
! ----- ! ---------------- !
! 1 ! Site 1 !
! ----- ! ---------------- !
! 2 ! Site 2 !
table2:
! t2_id ! tag !
! ----- ! ----------------!
! 3 ! Référencement !
! ----- ! ----------------!
! 4 ! Linking !
! ----- ! ----------------!
! 5 ! HTML !
table3:
! t1_id ! t2_id !
! ----- ! ----------!
! 1 ! 3 !
! ---- ! ---------- !
! 1 ! 4 !
! ---- ! ---------- !
! 2 ! 4 !
! ---- ! ---------- !
! 2 ! 5 !
My query (below) displays websites that have the tags 'Référencement' or 'Linking', so sites 1 and 2 are displayed, but this is not what I need. I would like to display websites having tags 'Référencement" and 'Linking' both (so here the 'site 1' only):
SELECT t1.*
FROM table1 t1, table3 t3
WHERE t1.t1_id = t3.t1_id
AND (t3.t2_id = 3 OR t3.t2_id = 4)
I hope I am being clear, sorry I am not fluent in English.
Thank in advance for your help.