This topic is locked

Copy all records from several fields to another table

10/28/2007 3:54:28 AM
PHPRunner General questions
L
luck author

Hi,
I have 2 table:
Table1 with fields:
Field1

Field2

Field3

Field4
and Table2 with fields:
Field5

Field6

Field7

Field8
I create Table3 with following fields:
Field9

Field10

Field11

Field12

Field13
What i need is to copy all de records from Table1 and Table2 to Table 3 but not from all fields.
I want to copy from Table1 from fields1, 3 and 4 to Table3 in fields9, 10 and 11.
Also i need to copy from Table2: fields4 and 7 to Table3 in fields12 and 13.
The result is to see all the records from specify fields from Table1 and 2 in specify fields from Table3.
Please tell me how to do that.
Thank you!

kujox 10/28/2007

Hi,

I have 2 table:
Table1 with fields:
Field1

Field2

Field3

Field4
and Table2 with fields:
Field5

Field6

Field7

Field8
I create Table3 with following fields:
Field9

Field10

Field11

Field12

Field13
What i need is to copy all de records from Table1 and Table2 to Table 3 but not from all fields.
I want to copy from Table1 from fields1, 3 and 4 to Table3 in fields9, 10 and 11.
Also i need to copy from Table2: fields4 and 7 to Table3 in fields12 and 13.
The result is to see all the records from specify fields from Table1 and 2 in specify fields from Table3.
Please tell me how to do that.
Thank you!


You can do it using a joined select, but you need to state which fields connect the two tables(1 and 2) together?

L
luck author 10/28/2007

quote]
You can do it using a joined select, but you need to state which fields connect the two tables(1 and 2) together?

[/quote]
Hi,
I think i need to select all the data from specified fields and to copy them to Table3 but i don't know how to do that. Please tell me waht is the code for that.
Thank you!

Sergey Kornilov admin 10/28/2007

You need to explain how and when it should work.
Do you need to do this just once? Use phpMyAdmin in this case.
Do you need to do this per user request?
Right it's not clear how this related to PHPRunner.

L
luck author 10/28/2007

You need to explain how and when it should work.

Do you need to do this just once? Use phpMyAdmin in this case.
Do you need to do this per user request?
Right it's not clear how this related to PHPRunner.


Yes, i need to do this per user request. Thank you in advance!

Sergey Kornilov admin 10/28/2007

Here is the sample code that allows you to insert some data from two tables into the third table:

INSERT INTO Table( Field1, Field2, Field3 )

SELECT Table1.Field1, Table1.Field2, Table2.Field3

FROM Table1

INNER JOIN Table2 ON

Table1.ID = Table2.ID


More info:

http://www.webcheatsheet.com/sql/interacti.../sql_insert.php

L
luck author 10/28/2007

Here is the sample code that allows you to insert some data from two tables into the third table:


INSERT INTO Table( Field1, Field2, Field3 )

SELECT Table1.Field1, Table1.Field2, Table2.Field3

FROM Table1

INNER JOIN Table2 ON

Table1.ID = Table2.ID


More info:

http://www.webcheatsheet.com/sql/interacti.../sql_insert.php


Thank you very much!