joomla
asked on
SQL Statement not working
SELECT itemid, CONCAT( "insert into tblmembers (ID,", GROUP_CONCAT( b.fieldname ) , ") values (", itemid, ",", GROUP_CONCAT( "'", data_txt, "'" ) , ");" )
FROM jos_sobi2_fields_data AS a
JOIN tablefields AS b ON (
a.`fieldid` = b.`fieldid`
)
GROUP BY itemid
ORDER BY itemid
LIMIT 0 , 30
Can anyone tell me why this statement doesn't create records in the table 'tblmembers'
tblmembers & jos_sobi2_fields_data & tablesfields all exist and are structured properly.
FROM jos_sobi2_fields_data AS a
JOIN tablefields AS b ON (
a.`fieldid` = b.`fieldid`
)
GROUP BY itemid
ORDER BY itemid
LIMIT 0 , 30
Can anyone tell me why this statement doesn't create records in the table 'tblmembers'
tblmembers & jos_sobi2_fields_data & tablesfields all exist and are structured properly.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I agree with above on the reason. You will need to use a MySQL prepared statement to run the dynamic sql created - http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
What exactly are you wanting to do? Just note that UPDATE WITH JOIN in MySQL is in the UPDATE, i.e.:
or
Otherwise, the syntax shown by Mark should work.
What exactly are you wanting to do? Just note that UPDATE WITH JOIN in MySQL is in the UPDATE, i.e.:
UPDATE a, b
SET a.column = b.column
WHERE a.key = b.key
;
or
UPDATE a JOIN b ON a.key = b.key
SET a.column = b.column
;
Otherwise, the syntax shown by Mark should work.
ASKER
Thanks, helps me a great deal.
regards
M
regards
M
If you really want the INSERTs to fire, then this should look more like INSERT INTO table SELECT ... syntax.