Left Outer Join in joomla sql?

947 views
Skip to first unread message

Soheil Novinfard

unread,
Dec 20, 2011, 4:36:44 AM12/20/11
to Joomla! Platform Development
hi,

what is equal to Left Outer Join in joomla sql?

and if not how can I do? Do I have to built all my query in simple
inline way?

Thanks

Mark Dexter

unread,
Dec 20, 2011, 11:11:02 AM12/20/11
to joomla-de...@googlegroups.com
You want to use the leftJoin() method of JDatabaseQuery. For example:
$query->leftJOIN('#__contact_details AS cd ON cd.user_id=u.id'); There
are a number of examples in the CMS. Good luck. Mark

Louis Landry

unread,
Dec 20, 2011, 1:32:47 PM12/20/11
to joomla-de...@googlegroups.com
Hi Soheil,

As Mark points out JDatabaseQuery can handle this without any issues.  This would be a great opportunity for someone to write up a tutorial chapter on how to use JDatabaseQuery for our user manual.

$query = $db->getQuery(true);

$query->select('table_one.field1, table_two.field2');
$query->from('table_one');
$query->leftJoin('table_two ON table_one.pk = table_two.fk');

OR you could be more explicit:

$query->join('LEFT OUTER', 'table_two ON table_one.pk = table_two.fk');
Reply all
Reply to author
Forward
0 new messages