GARAIS Posted April 21, 2011 Report Share Posted April 21, 2011 Parādat lūdzu kāds query lai izvilktu draugu draugus :) mana draugu tabulas struktūra ir id,friend_1_id,friend_2_id,accept_date. ieraksti dubultojas mainoties friend_1_id ar friend_2_id vietām. Jau 2 mēnešus domāju kā izveidot bet nekādīgi nesanāk :( paldies jau iepriekš :) Quote Link to comment Share on other sites More sharing options...
sandis_m Posted April 21, 2011 Report Share Posted April 21, 2011 (edited) Parādat lūdzu kāds query lai izvilktu draugu draugus :) mana draugu tabulas struktūra ir id,friend_1_id,friend_2_id,accept_date. ieraksti dubultojas mainoties friend_1_id ar friend_2_id vietām. Jau 2 mēnešus domāju kā izveidot bet nekādīgi nesanāk :( paldies jau iepriekš :) apmēram kaut kas uz to pusi: SELECT u.uid,vards,cits_useralauks, f.*, ff.* FROM `users` u, `friendships` f, `friendships` ff WHERE f.myid='". uid ."' AND f.friend_1_id = ff.friend_2_id AND ff.friend_1_id = u.uid AND ff.friend_1_id != f.friend_1_id AND f.friend_1_id != ff.friend_1_id AND ff.friend_1_id != ". uid ." AND f.myid != ff.friendid AND ff.friend_1_id != f.friend_2_id AND f.friend_1_id != ff.friend_1_id GROUP BY ff.friend_1_id ORDER BY ff.friend_1_id DESC, ff.friend_1_id DESC Edited April 21, 2011 by who_i_am Quote Link to comment Share on other sites More sharing options...
GARAIS Posted April 21, 2011 Author Report Share Posted April 21, 2011 apmēram kaut kas uz to pusi: SELECT u.uid,vards,cits_useralauks, f.*, ff.* FROM `users` u, `friendships` f, `friendships` ff WHERE f.myid='". uid ."' AND f.friend_1_id = ff.friend_2_id AND ff.friend_1_id = u.uid AND ff.friend_1_id != f.friend_1_id AND f.friend_1_id != ff.friend_1_id AND ff.friend_1_id != ". uid ." AND f.myid != ff.friendid AND ff.friend_1_id != f.friend_2_id AND f.friend_1_id != ff.friend_1_id GROUP BY ff.friend_1_id ORDER BY ff.friend_1_id DESC, ff.friend_1_id DESC Jā vissu saprotu bet kā jāveido tops? ar for? un kas ir f.*, ff.*? Quote Link to comment Share on other sites More sharing options...
Kaklz Posted April 21, 2011 Report Share Posted April 21, 2011 Rēķinies, ka SQL šim mērķim strādās normālā laikā tikai ar ļoti nelielu lietotāju skaitu. Quote Link to comment Share on other sites More sharing options...
GARAIS Posted April 21, 2011 Author Report Share Posted April 21, 2011 Rēķinies, ka SQL šim mērķim strādās normālā laikā tikai ar ļoti nelielu lietotāju skaitu. Bet man vajadzētu ar lielu lietotāju skaitu man jau 8563 lietotāji piereģistrējušies ;) Quote Link to comment Share on other sites More sharing options...
sandis_m Posted April 21, 2011 Report Share Posted April 21, 2011 Bet man vajadzētu ar lielu lietotāju skaitu man jau 8563 lietotāji piereģistrējušies ;) Portāls kaut kāds? Kāda adrese? Quote Link to comment Share on other sites More sharing options...
GARAIS Posted April 21, 2011 Author Report Share Posted April 21, 2011 Portāls kaut kāds? Kāda adrese? http://garais.ngames.lv/ pagaidaam veel daudz kaa nav bet drizumaa ;) Quote Link to comment Share on other sites More sharing options...
Faks Posted April 21, 2011 Report Share Posted April 21, 2011 vai tad nau vieglak ar leftoin taisit ? plus atrak darbosies ! Quote Link to comment Share on other sites More sharing options...
sandis_m Posted April 21, 2011 Report Share Posted April 21, 2011 vai tad nau vieglak ar leftoin taisit ? plus atrak darbosies ! Tam jau nav nozīmes ar ko, galvenais ir ātrdarbība utt. Ja lietotāju skaits būs ļoti liels, tad šis variants neder. Quote Link to comment Share on other sites More sharing options...
Faks Posted April 21, 2011 Report Share Posted April 21, 2011 nu tad jataisa kaut kas lidzings uz pm sistemu tad bus 100% atraks ta vismaz es spriezu :) Quote Link to comment Share on other sites More sharing options...
GARAIS Posted April 21, 2011 Author Report Share Posted April 21, 2011 a mans variants der? ;) Quote Link to comment Share on other sites More sharing options...
Faks Posted April 21, 2011 Report Share Posted April 21, 2011 a mans variants der? ;) pēc idejas jā tikai kad būs vismaz 500 lietotāji sāksies lēnā izviklšāna no db :) bet lidz tam bridim var dzivot . Quote Link to comment Share on other sites More sharing options...
spainis Posted April 21, 2011 Report Share Posted April 21, 2011 kā šis fakts - 500 lietotāji ir nomērīts? Quote Link to comment Share on other sites More sharing options...
GARAIS Posted April 22, 2011 Author Report Share Posted April 22, 2011 pēc idejas jā tikai kad būs vismaz 500 lietotāji sāksies lēnā izviklšāna no db :) bet lidz tam bridim var dzivot . bet kā izveidot lai viss iet ātri? :) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 22, 2011 Report Share Posted April 22, 2011 Ar kešošanu. Laikam... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.