Jump to content
php.lv forumi

Draugi


GARAIS

Recommended Posts

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š :)

Link to comment
Share on other sites

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 by who_i_am
Link to comment
Share on other sites

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.*?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...