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
  • 369,052
  • 73
  • 620
  • 1,021
algorithmicCoder
  • 6,395
  • 20
  • 67
  • 117

5 Answers5

7

MySQL doesn't have INTERSECT.

Community
  • 1
  • 1
Ignacio Vazquez-Abrams
  • 740,318
  • 145
  • 1,296
  • 1,325
0

JOIN JOIN , Is that valid syntax?

zad
  • 3,305
  • 2
  • 22
  • 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
  • 455
  • 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,374
  • 6
  • 35
  • 56
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
  • 27,507
  • 6
  • 41
  • 51