Page 1 of 1

Whats the best way to copy a row mySQL table?

Posted: Thu Jul 24, 2014 8:01 pm
by DavJans
I need to copy a row in my table to another row, but one column cannot contain the same unique ID, that ID I need to tell it during copy.

Re: Whats the best way to copy a row mySQL table?

Posted: Thu Jul 24, 2014 10:51 pm
by Klaus
Scusi, no capisce 8)

Re: Whats the best way to copy a row mySQL table?

Posted: Thu Jul 24, 2014 11:51 pm
by DavJans
I found this, anyway to translate to livecode? It copies everything from one record to the next except the first name and username


id first_name last_name username address city state
1 John Doe johndoe 123 Street Chicago IL

INSERT INTO `users` ( username, first_name, last_name, address, city, state )
SELECT "janedoe", "Jane", last_name, address, city, state
FROM `users`
WHERE `username`='johndoe'

id first_name last_name username address city state
1 John Doe johndoe 123 Street Chicago IL
2 Jane Doe janedoe 123 Street Chicago IL

Re: Whats the best way to copy a row mySQL table?

Posted: Fri Jul 25, 2014 8:33 pm
by phaworth
So username and firstname are the columns that have different values?

The INSERT statement you have should work fine with one small change - the string literals for JaneDoe and Jane should be in single quotes not double, although it will probably still work with doubles.

Just call revExecuteSQL with it and check the result after to makes sure it worked OK.

Re: Whats the best way to copy a row mySQL table?

Posted: Fri Aug 01, 2014 5:17 pm
by DavJans
I tried it and it works great thank you. single quote.