SELECT
CONCAT(
'INSERT INTO ',
CONCAT( '`', table_name, '`' ),
' (',
GROUP_CONCAT( CONCAT( '`', COLUMN_NAME, '`' ) ),
') VALUE (',
GROUP_CONCAT( CONCAT( '@', COLUMN_NAME ) ),
');'
)
FROM
information_schema.COLUMNS
WHERE
table_schema = 'tsc_small'
AND table_name = 'users'
AND column_key != 'PRI'
SELECT
CONCAT( 'UPDATE ', CONCAT( '`', table_name, '`' ), GROUP_CONCAT( CONCAT( ' SET `', COLUMN_NAME, '` = @', COLUMN_NAME ) ), ' WHERE ...;' )
FROM
information_schema.COLUMNS
WHERE
table_schema = 'tsc_small'
AND table_name = 'users'
AND column_key != 'PRI'
SELECT
CONCAT(
CONCAT(
'INSERT INTO ',
CONCAT( '`', table_name, '`' ),
' (',
GROUP_CONCAT( CONCAT( '`', COLUMN_NAME, '`' ) ),
') VALUE (',
GROUP_CONCAT( CONCAT( '@', COLUMN_NAME ) ),
')'
),
' ON DUPLICATE KEY UPDATE ',
CONCAT(
GROUP_CONCAT( CONCAT( '`', COLUMN_NAME, '`=@', COLUMN_NAME ) ))
)
FROM
information_schema.COLUMNS
WHERE
table_schema = 'cross_over_repurchase'
AND table_name = 'user'