Pentiums Posted March 28, 2009 Report Share Posted March 28, 2009 Labrīt! Ir tabula `friendship` [id|friend|owner] (Kas ar ko ir draugs) Ir tabula `friends` [id|name|surname|utt...] (Pašu lietotāju tabula) Gribas izvilkt tos kas nav mani draugi, mēģināju šādi: SELECT friends.name, friends.surname, friends.bday_y, friends.bday_m, friends.bday_d, friends.nick, friends.photo, friends.city, friends.id, friendship.friend friendship_id FROM friends LEFT JOIN friendship ON friendship.friend=friends.id WHERE friendship.owner != '".$myinfo['id']."' AND friendship.friend != '".$myinfo['id']."' ORDER BY RAND() LIMIT 4 Izvelkās tie kas nesatur manu id `friendship.friend` un `friendship.owner` laukā, bet ir taču arī mani draugi draugos ar citiem lietotājiem, tātad viņi tomēr izvelkas!! Kāds var palīdzēt izlabot šo lietu? Un kādi ieteikumi? Vajag taisīt vel kādu citu tabulu klāt, vai kādu lauku? Paldies jau iepriekš! Quote Link to comment Share on other sites More sharing options...
Gints Plivna Posted March 28, 2009 Report Share Posted March 28, 2009 Īsti neierubījos problēmā (laikam vēl rīts un kafijas trūkums organismā :) , bet vai tur vienkārši nevajag OR AND'a vietā? Gints Plivna http://datubazes.wordpress.com Quote Link to comment Share on other sites More sharing options...
Pentiums Posted March 28, 2009 Author Report Share Posted March 28, 2009 Tas neko nemaina :( Quote Link to comment Share on other sites More sharing options...
Delfins Posted March 28, 2009 Report Share Posted March 28, 2009 draugu draugi ir visparastakais koks. Ja tu gribi izvilkt ne-draugus, tad tevvispirms jauzraksta procedura/skats/cache tabula, kura satures visus draugus un dr-draugus rekursiva un tikai tad vari taisit not-exists. Var protams to visu uzreiz rekursivi taisit, bet tas bus ljoti darbietilpigs process - izet cauri katrai "nodei" un to child ierakstiem... Atrakais variants updeitot string lauku katram lietotajam, kadi tad ir vinjam draugu un dr-draugu ID. ta nebus jamekle pa koku, bet pa ljoti garu stringu. bet tas bus atrak. 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.