If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Query needed which must works in PHP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-03-10, 11:09
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
Query needed which must works in PHP

Hello,
I am working with PHP5 and mysql.
I am having 3 tables in database, as shown in image.
So i want to display the avatar and name of the friends for the current user.
  1. So when i query for the user 11 means, it must see the friendid of the user 11 from friends table which are 12 and 13.
  2. Next that 12 and 13 must be looked up on users table for username being the friendid of friend table is equal to id of users table
  3. Finally, for that 12 and 13 avatarid and avatarext must be looked from avatar table.
I tried this which displays only avatarid for the queried user, but i know how to join the other table.
Any ideas?
Thankyou
Code:
                                       SELECT avatarext,avatarid
					FROM avatar
					WHERE userid IN(
					SELECT friendid
					FROM friend
					WHERE userid='11';
Reply With Quote
  #2 (permalink)  
Old 02-03-10, 11:43
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
Moderator: Please delete this thread, this is a duplicate thread. Thankyou
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On