softmafia
Posts: 44
|
| Posted: 08/08/2009, 7:30 AM |
|
I wan to be able to copy data from a particular table to another with one record form
For Example i have two tables ( TablesA and TableB)
TABLE A
id
name
surname
age
TABLE B
id
name
surname
age
There Is a Record form that is used to input data into Table A i want to be able to use update to copy the same data to TABLE B when i click to update
please can anyone Help me with this or the Custom Code thanks
_________________
softmafia |
 |
 |
ckroon
Posts: 869
|
| Posted: 08/08/2009, 10:48 PM |
|
http://www.databasejournal.com/features/mssql/article.p...-to-Another.htm
Gonna have to do some Custom SQL commands on an After Insert/Update event.
_________________
Walter Kempees...you are dearly missed. |
 |
 |
mentecky
Posts: 321
|
| Posted: 08/09/2009, 10:11 AM |
|
softmafia,
In your record After Update event you'd need something like:
$db = new clsInternet(); // change for your DB class
$SQL = "INSERT INTO tableB (name, surname, age) FROM SELECT name, surname, age FROM tablea WHERE id=".CCGetParam("id","");
$db->query($SQL);
Hope that helps!
Rick
_________________
http://www.ccselite.com |
 |
 |
ckroon
Posts: 869
|
| Posted: 08/09/2009, 10:12 PM |
|
Get rid of the first FROM :)
_________________
Walter Kempees...you are dearly missed. |
 |
 |
mentecky
Posts: 321
|
| Posted: 08/09/2009, 10:35 PM |
|
Thanks CK... I hate when my fingers do stuff before my mind thinks about it.
Rick
_________________
http://www.ccselite.com |
 |
 |
GrzegorzL
Posts: 13
|
| Posted: 08/21/2009, 5:46 AM |
|
Perfect
Many thanks
|
 |
 |
TonyReid
Posts: 159
|
| Posted: 08/22/2009, 2:30 PM |
|
I'd usually use the SELECT INTO statement when copying into other tables.
Not sure if there is much performance benefit doing it that way as opposed to above, but I think it might be a little faster.
_________________
-----------
PHP/indy Game Developer - http://www.AbsoluteBreeze.co.uk |
 |
 |
mentecky
Posts: 321
|
| Posted: 08/22/2009, 2:44 PM |
|
TonyReid,
I believe after the server optimizes the query they end up being pretty much the same. I prefer INSERT INTO simply because it's easy to read when debugging. Just a personal preference.
You may well be right if were talking a large dataset though.
Rick
_________________
http://www.ccselite.com |
 |
 |