Search
 
SCRIPT & CODE EXAMPLE
 

SQL

mysql copy row with new id

CREATE TEMPORARY TABLE tmp SELECT * FROM sitelog WHERE 1=1;
ALTER TABLE tmp DROP COLUMN `ID`;
INSERT INTO sitelog SELECT 0, tmp.* FROM tmp;
DROP TEMPORARY TABLE tmp;
Comment

MySQL copy row with *

CREATE TEMPORARY TABLE tmp SELECT * from invoices WHERE ...;
    ALTER TABLE tmp drop ID; # drop autoincrement field
    # UPDATE tmp SET ...; # just needed to change other unique keys
    INSERT INTO invoices SELECT 0,tmp.* FROM tmp;
    DROP TABLE tmp;
Comment

PREVIOUS NEXT
Code Example
Sql :: create a table from one field of another table 
Sql :: SQL Comments Within Statements 
Sql :: cross join sl 
Sql :: psql: error: FATAL: database "odoo" does not exist 
Sql :: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails 
Sql :: description query in sql 
Sql :: Triggers Syntax 
Sql :: convert minutes to hours in sql 
Sql :: how to reset the identity column in sql server 
Sql :: mysql regex select 
Sql :: postgresql create user roles 
Sql :: google sheets filter rows above current cell 
Sql :: snowflake insert select 
Sql :: disable database droping sql 
Sql :: mql4 sleep 
Sql :: sqlalchemy query join many to many 
Sql :: psql owner of database 
Sql :: sql online compiler 
Sql :: right join 
Sql :: sql server port number 
Sql :: sqlalchemy _in array sqlite 
Sql :: import mysql dump 
Sql :: where keyword sql 
Sql :: How to drop table in mysql ? 
Sql :: missing index for constraint error in mysql 
Sql :: mysql case sensitive ? 
Sql :: how to select only first 3 characters in sql 
Sql :: Column count of mysql.user is wrong. Expected 42, found 44. The table is probably corrupted 
Sql :: how to connect docker container to gcp sql server 
Sql :: sql run online 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =