teror Posted July 29, 2005 Report Share Posted July 29, 2005 Vai var kautko šitādu izdarīt bez subselecta? SELECT COUNT(*) AS users FROM user WHERE (SELECT COUNT(*) FROM user_stuff WHERE user_stuff.user_id = user.id) > 10 Link to comment Share on other sites More sharing options...
bubu Posted July 29, 2005 Report Share Posted July 29, 2005 (edited) 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 July 29, 2005 by bubu Link to comment Share on other sites More sharing options...
Roze Posted July 29, 2005 Report Share Posted July 29, 2005 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 More sharing options...
v3rb0 Posted July 29, 2005 Report Share Posted July 29, 2005 (edited) .. Edited July 29, 2005 by v3rb0 Link to comment Share on other sites More sharing options...
Recommended Posts