I'm trying to convert a delete query with left join to use JDatabaseQuery, but I am encountering an issue in the query. The query that I'm trying to convert and which works is the following :
$db->setQuery("DELETE u FROM #__mycomponent_users AS u
LEFT JOIN #__users AS ju ON u.userid=ju.id
WHERE ju.username IS NULL");
I have converted it to JDatabaseQuery, with the following code:
$db->getQuery(true)
->delete($db->quoteName('#__mycomponent_users', 'u'))
->leftJoin($db->quoteName('#__users', 'ju') . ' ON u.userid=ju.id')
->where('ju.username IS NULL');
$db->setQuery($query);
In this, it returns the following error :
Syntax error near 'AS
u
LEFT JOINjt5il_users
ASju
ON u.userid=ju.id WHERE ju.username IS NUL'
So how can I make this query work by using JDatabaseQuery?