0

Trying to see what video categories "me_id" and "you_id" have both watched with:

SELECT c.title, COUNT(*) AS popularity 
FROM video v 
JOIN user u ON v.user_id = u.id 
JOIN v_cat vc ON c.id = vc.vid_id 
JOIN cat c ON c.id = vc.cat_id
JOIN u_cat uc ON uc.cat_id = c.id  
WHERE uc.user_id = '$me_id'

INTSERSECT 

SELECT c.title, COUNT(*) AS popularity 
FROM video v 
JOIN user u ON v.user_id = u.id 
JOIN v_cat vc ON c.id = vc.vid_id 
JOIN cat c ON c.id = vc.cat_id
JOIN u_cat uc ON uc.cat_id = c.id  
WHERE uc.user_id = '$you_id'

GROUP BY c.title 
ORDER BY uc.id DESC LIMIT 0, 10

I am working with PHP/MYSQL any thoughts?

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
algorithmicCoder
  • 6,595
  • 20
  • 68
  • 117

5 Answers5

7

MySQL doesn't have INTERSECT.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

JOIN JOIN , Is that valid syntax?

zad
  • 3,355
  • 2
  • 24
  • 25
0

FROM video v JOIN JOIN v_cat vc ON c.id = vc.vid_id

in the above line u have to use join one time..

mohan
  • 453
  • 1
  • 5
  • 17
0

I see two consecutive JOIN keywords in your first select but without any error message this is going to be difficult to debug.

Matt Dodge
  • 10,833
  • 7
  • 38
  • 58
0

Instead of INTERSECT, you can use the key word UNION or UNION ALL, this basically will do the intersection select. See http://dev.mysql.com/doc/refman/5.0/en/union.html

Bud Damyanov
  • 30,171
  • 6
  • 44
  • 52