Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Reduced tabbing, improved English, added tag
Source Link
mickmackusa
  • 4.8k
  • 4
  • 18
  • 48

I'amI'm trying to convert a delete query with left join to use JDatabaseQuery, but i encounterI am encountering an issue in the query. The query that iI'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 returnreturns the following error :

Syntax error near 'AS u LEFT JOIN jt5il_users AS ju ON u.userid=ju.id WHERE ju.username IS NUL'

So how tocan I make working thethis query work by using JDatabaseQuery  ?

Thanks by advance

I'am trying to convert delete query with left join to use JDatabaseQuery, but i encounter an issue in the query. The query that i 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 return the following error :

Syntax error near 'AS u LEFT JOIN jt5il_users AS ju ON u.userid=ju.id WHERE ju.username IS NUL'

So how to make working the query by using JDatabaseQuery  ?

Thanks by advance

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 JOIN jt5il_users AS ju ON u.userid=ju.id WHERE ju.username IS NUL'

So how can I make this query work by using JDatabaseQuery?

Bumped by Community user
Source Link
user3533235
  • 612
  • 3
  • 14

Delete query and left join with JDatabaseQuery doesn't work

I'am trying to convert delete query with left join to use JDatabaseQuery, but i encounter an issue in the query. The query that i 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 return the following error :

Syntax error near 'AS u LEFT JOIN jt5il_users AS ju ON u.userid=ju.id WHERE ju.username IS NUL'

So how to make working the query by using JDatabaseQuery ?

Thanks by advance