Log in

View Full Version : SQL query help


Nutz
09-01-2005, 11:57 PM
Hi,
Can some one help me with a sql query:

$SQL = "SELECT * FROM " .TABLE_PREFIX ."imgtools";

That query works fine and goes on to a while statement listing all the userid's in the table ("imgtools") :)
But I would also like the query to get the actual usernames for each userid.
Any help would be much appreciated I?m at a loss of how to do it with out a query for every userid.

Many Thanks
Mat

Andreas
09-02-2005, 12:01 AM
$SQL = "SELECT imgtools.*, user.username FROM " . TABLE_PREFIX . "imgtools AS imgtools LEFT JOIN " . TABLE_PREFIX . "user AS user ON (user.userid=imgtools.userid)";

Nutz
09-03-2005, 12:01 AM
Once again thanks,
Is there any chance the same query could get information from the usergroup table?
I want to create $musername containing the right usergroups html open and close tab.

Many Thanks
Mat