Jump to content
php.lv forumi

subselect


teror

Recommended Posts

Ja pareizi saprotu, tad jādabū useru_stafa skaits katram userim, tad ja tas >10?

SELECT user_id, COUNT(*) as cnt FROM user_stuff GROUP BY user_id HAVING cnt>10

 

Edit: ā, nē. Vajag tikai useru skaitu, kuru stafs>10... laikam nevar, vismaz nenāk prātā nekas.

Edited by bubu
Link to comment
Share on other sites

Hmm kapeec tad nevar? Uz ātru šeibu apmēram šādi.

SELECT COUNT(*) as stafskaits FROM user_stuff LEFT JOIN user ON (user_stuff.user_id = user.id) WHERE stafskaits > 10

 

protams pieliec ttur citus laukus kur tev vajag..

Link to comment
Share on other sites

×
×
  • Create New...