Whats the best way to copy a row mySQL table?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Whats the best way to copy a row mySQL table?

Post 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.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

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

Post by Klaus »

Scusi, no capisce 8)
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

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

Post 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
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

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

Post 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.
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

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

Post by DavJans »

I tried it and it works great thank you. single quote.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här
Post Reply