Update Table dynamically in mySQL

Posted On // Leave a Comment

So, if you want to update table in mySQL dynamically here is the code.


SET @table = 'kas_permohonan_m';
SET @update = 'status=''TEST''';
SET @where = 'nomor = ''KP010001''';
SET @SQL = CONCAT('UPDATE ',@table,
                  ' SET '  ,@update,
                  ' WHERE ',@where);
PREPARE stmt FROM @SQL;
EXECUTE stmt;

0 komentar: