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
Bumped by Community user
Bumped by Community user
Bumped by Community user
Formatted code. Added code from comment. Improved spelling and grammar. Added some whitespace for readability. Removed unnecessary verbiage.
Source Link

how How can I translate SQL code into something that Joomla will take?

friends at joomla.stackexchange.com, II am in the same case discussed on https://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table  , thisthat is, I need to copy the value of a column from tableA to tableB based on a common column in each table. I

I have used the suggested code inside of phpmyAdminPHPMyAdmin, and it works perfectly. UPDATE TableB SET TableB.value = ( SELECT TableA.value FROM TableA WHERE TableA.name = TableB.name ); My:

UPDATE TableB 
SET TableB.value = (
    SELECT TableA.value 
    FROM TableA
    WHERE TableA.name = TableB.name
);

My problem is that I have been unable to translate this into something that I can use inside of my mod_xxx.phpmod_xxx.php file. On the same stackoverflowStack Overflow page, there is a suggested code that uses mysql_querymysql_query and supposedly works, but Joomla doesn´t accept it. I know that any code has to be translated to Joomla's coding standards but I have spent three complete days trying it with no success.

I have tried the following code unsuccessfully:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query ->UPDATE ('#__gruposlocales')
       ->SET ('#__gruposlocales.name') =
             (SELECT ('#__community_groups.name')
              FROM ('#__community_groups')
              WHERE ('#__community_groups.ownerid = #__gruposlocales.id'));
$db->setQuery($query);
$result = $db->execute(); 

As you may guess, I am not knowledgeable on PHP coding, so I am in serious need of your help, please. My question is how can I translate the upper code into something that Joomla will take? Thank you very much in advance for any piece of advice.

how can I translate SQL code into something that Joomla will take?

friends at joomla.stackexchange.com, I am in the same case discussed on https://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table  , this is, I need to copy the value of a column from tableA to tableB based on a common column in each table. I have used the suggested code inside of phpmyAdmin, and it works perfectly. UPDATE TableB SET TableB.value = ( SELECT TableA.value FROM TableA WHERE TableA.name = TableB.name ); My problem is that I have been unable to translate this into something that I can use inside of my mod_xxx.php file. On the same stackoverflow page, there is a suggested code that uses mysql_query and supposedly works, but Joomla doesn´t accept it. I know that any code has to be translated to Joomla's coding standards but I have spent three complete days trying it with no success. As you may guess, I am not knowledgeable on PHP coding, so I am in serious need of your help, please. My question is how can I translate the upper code into something that Joomla will take? Thank you very much in advance for any piece of advice.

How can I translate SQL code into something that Joomla will take?

I am in the same case discussed on https://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table, that is, I need to copy the value of a column from tableA to tableB based on a common column in each table.

I have used the suggested code inside of PHPMyAdmin, and it works perfectly:

UPDATE TableB 
SET TableB.value = (
    SELECT TableA.value 
    FROM TableA
    WHERE TableA.name = TableB.name
);

My problem is that I have been unable to translate this into something that I can use inside of my mod_xxx.php file. On the same Stack Overflow page, there is a suggested code that uses mysql_query and supposedly works, but Joomla doesn´t accept it. I know that any code has to be translated to Joomla's coding standards but I have spent three complete days trying it with no success.

I have tried the following code unsuccessfully:

$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query ->UPDATE ('#__gruposlocales')
       ->SET ('#__gruposlocales.name') =
             (SELECT ('#__community_groups.name')
              FROM ('#__community_groups')
              WHERE ('#__community_groups.ownerid = #__gruposlocales.id'));
$db->setQuery($query);
$result = $db->execute(); 

As you may guess, I am not knowledgeable on PHP coding, so I am in serious need of your help, please. My question is how can I translate the upper code into something that Joomla will take?

Source Link

how can I translate SQL code into something that Joomla will take?

friends at joomla.stackexchange.com, I am in the same case discussed on https://stackoverflow.com/questions/11709043/mysql-update-column-with-value-from-another-table , this is, I need to copy the value of a column from tableA to tableB based on a common column in each table. I have used the suggested code inside of phpmyAdmin, and it works perfectly. UPDATE TableB SET TableB.value = ( SELECT TableA.value FROM TableA WHERE TableA.name = TableB.name ); My problem is that I have been unable to translate this into something that I can use inside of my mod_xxx.php file. On the same stackoverflow page, there is a suggested code that uses mysql_query and supposedly works, but Joomla doesn´t accept it. I know that any code has to be translated to Joomla's coding standards but I have spent three complete days trying it with no success. As you may guess, I am not knowledgeable on PHP coding, so I am in serious need of your help, please. My question is how can I translate the upper code into something that Joomla will take? Thank you very much in advance for any piece of advice.