Please help with coding

S

Sheela

I have a table, table1 with fields fild1, field2,..start
position, End Position.
And also another table, table2 with fields field1, field2,
.. Position.
I need to insert data from table 1 to table 2, all the
fields has same information from the table1, except
position field.
The position field value starts from table1.start position
and ends with table1.end position.
It might be easy to understand if I give an example as
follows:
Could some one please help me how to do this?
TIA.
Sheela.

Table1:
Field1 field2 start position end position
A A 1 3
B B 8 9
....

Table2:
Field1 field2 Position
A A 1
A A 2
A A 3
B B 8
B B 9
....
 
J

John Vinson

I have a table, table1 with fields fild1, field2,..start
position, End Position.
And also another table, table2 with fields field1, field2,
. Position.
I need to insert data from table 1 to table 2, all the
fields has same information from the table1, except
position field.
The position field value starts from table1.start position
and ends with table1.end position.
It might be easy to understand if I give an example as
follows:
Could some one please help me how to do this?
TIA.
Sheela.

Table1:
Field1 field2 start position end position
A A 1 3
B B 8 9
...

Table2:
Field1 field2 Position
A A 1
A A 2
A A 3
B B 8
B B 9
...

This can be done with the help of an auxiliary table. I routinely
create a table Num with just one field N, filled with values 0 through
10000 or so.

An Append query like

INSERT INTO Table2
SELECT Table1.Field1, Table1.Field2, Num.N
FROM Table1, Num
WHERE Num.N >= Table1.[Start Position]
AND Num.N <= Table1.[End Position]

This uses a normally undesirable "Cartesian Join", i.e. no join line -
but it will do just what you ask.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top