TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-02-2008, 02:47 PM   #1 (permalink)
The Wanderer
 
kokjj87's Avatar
 
Join Date: Oct 2008
Posts: 18
Thanks: 0
kokjj87 is on a distinguished road
Default join 3 table?

Hi, to keep things simple I have 3 table..

user
id, username

blog
id, blog_post, user_id

blog_comment
id, blog_id

With blog_id in the blog_comment, i wan to retrieve the username, how do i do it?.. (I need the query string)

Thanks
kokjj87 is offline  
Reply With Quote
Old 12-02-2008, 04:13 PM   #2 (permalink)
The Frequenter
Newcomer 
 
xenon's Avatar
 
Join Date: Dec 2007
Location: Bucharest, Romania
Posts: 438
Thanks: 3
xenon is on a distinguished road
Default

Code:
SELECT u.*, b.*, bc.* FROM blog_comment bc LEFT JOIN blog b ON(b.id=bc.blog_id) LEFT JOIN user u ON(u.id=b.user_id)
That will return the result just fine, although it can be optimized.
__________________
I have optimistic thoughts, even though sometimes (if not always) life's a bitch.
xenon is offline  
Reply With Quote
Old 12-02-2008, 08:39 PM   #3 (permalink)
The Acquainted
 
KingOfTheSouth's Avatar
 
Join Date: Oct 2008
Location: Cincinnati
Posts: 151
Thanks: 14
KingOfTheSouth is on a distinguished road
Default

Code:
$get = mysql_query("
		SELECT 
			nrank,pimp,hoes,thugs,guests,rating,thugskilled,hoeskilled,Pimp.worth,status,
			Crew.icon
		FROM 
			$tab[pimp] Pimp LEFT OUTER JOIN
			$tab[crew] Crew ON Pimp.crew = Crew.id
		WHERE 
			Pimp.rid='$round' 
		ORDER BY 
			nrank ASC 
		LIMIT 50;"
	);
   while ($usr = mysql_fetch_array($get)){
That is something I pulled some of my code Is that more of what you are looking for? A Query that is jointed?
KingOfTheSouth is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lookups table drewbee Advanced PHP Programming 0 07-15-2008 08:21 PM
MySQL syntax for table join on delete delayedinsanity General 5 04-03-2008 05:39 PM
Tables joining other Tables? Orc MySQL & Databases 6 02-09-2008 09:42 PM
Need your feedback Tanax Absolute Beginners 29 10-11-2007 04:50 PM
How to check if a table exists? Haris General 8 09-19-2007 09:04 PM


All times are GMT. The time now is 08:15 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design