The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
Understanding LEFT JOIN
I've run into a snag trying to use LEFT JOIN to cut out a query. I'm just a cut-n-paste coder so I can't figure this one out. I am after info from three tables, it's working now with two, but on the third it goes stupid on me. It only shows one listing with id's from seperate.
This is the working code with two tables: Code:
$result_list = $DB_site->query(" SELECT vbgarage_users.*, user.username, user.usertitle FROM " . TABLE_PREFIX . "vbgarage_users AS vbgarage_users LEFT JOIN " . TABLE_PREFIX . "user ON vbgarage_users.userid = user.userid ORDER BY user.username ASC LIMIT $pos,$perpage "); Code:
$result_image = $DB_site->query(" SELECT vbgarage_images.* FROM " . TABLE_PREFIX . "vbgarage_images WHERE vbgarage_images.userid = $list[userid] ORDER BY vbgarage_images.imageid ASC LIMIT 1 "); |
#2
|
||||
|
||||
[sql]$result_list = $DB_site->query("
SELECT vbgarage_users.*, vbgarage_images.*, user.username, user.usertitle FROM " . TABLE_PREFIX . "vbgarage_users AS vbgarage_users, " . TABLE_PREFIX . "vbgarage_images AS vbgarage_images LEFT JOIN " . TABLE_PREFIX . "user ON vbgarage_users.userid = user.userid WHERE vbgarage_images.userid = $list[userid] ORDER BY user.username ASC, vbgarage_images.imageid ASC LIMIT $pos,$perpage ");[/sql]Does that work in your environment? |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|