| Author |
Topic |
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-01-08 : 10:50:27
|
| I have tblA with below columnsCol1 -----Col2-------Col3--------Col4---------Col52315 -----DER---------34----------TR----------email (1st row)4325 -----MaRK---------DATA--------UT----------email (2nd Row)MY QUESTION : How to enter each row from tblA into the other table(tblB) like below. 1st Modified row of the inserted table from 1 st row of tblA2nd Modified row of the inserted table from 1 st row of tblASol1 -----Sol2-------Sol3--------Sol4------Sol52315 -----DER67---------34----------RTR-----email (1st from tblA)2315 -----DER67---------64----------TRT-------email (1st row tblA)Also I need to insert data sorted by column Sol1. All the above said is a template table to be imported in to oUR ERP software. PLEASE HELP |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-08 : 10:54:49
|
you need to state the business rules how to get fromthisquote: 2315 -----DER---------34----------TR----------email (1st row)
to thisquote: Sol1 -----Sol2-------Sol3--------Sol4------Sol52315 -----DER67---------34----------RTR-----email (1st from tblA)2315 -----DER67---------64----------TRT-------email (1st row tblA)
KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-01-08 : 11:06:11
|
Can you explain How??quote: Originally posted by khtan you need to state the business rules how to get fromthisquote: 2315 -----DER---------34----------TR----------email (1st row)
to thisquote: Sol1 -----Sol2-------Sol3--------Sol4------Sol52315 -----DER67---------34----------RTR-----email (1st from tblA)2315 -----DER67---------64----------TRT-------email (1st row tblA)
KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-08 : 11:18:31
|
| You need to give more explanation about how you will get values specified in o/p. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-01-08 : 11:27:32
|
quote: Originally posted by Vaishu Can you explain How??quote: Originally posted by khtan you need to state the business rules how to get fromthisquote: 2315 -----DER---------34----------TR----------email (1st row)
to thisquote: Sol1 -----Sol2-------Sol3--------Sol4------Sol52315 -----DER67---------34----------RTR-----email (1st from tblA)2315 -----DER67---------64----------TRT-------email (1st row tblA)
KH[spoiler]Time is always against us[/spoiler]
Not me. You. You need to tell us HOW. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-01-08 : 11:36:24
|
HiI am about enter data from one table (tbl A)insert into 5 other tables. one of the 5 table need to have 2 rows for each Number in Col1 of tblA.ex1: tblA Col1 123 (if the Col1 have 123 then Sol1 of tbl B must have 123 and column 'linenum' must have the value of '32' SECOND row of the tbl B123 and 'linenum' must have the value of '64'.ex2: tblB Sol1----LineNum 123-----32 123-----64I can use SQL procedure to get and modify the record from tblA. In short how insert one data as two rowex : Selcet A AS 123, A AS 123 from tbl AINSERT INTO tblB (Sol1) Expected result is like belowex: tbl BSol1123123quote: Originally posted by visakh16 You need to give more explanation about how you will get values specified in o/p.
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-08 : 11:52:41
|
| And where do you get other values (RTR,TRT.. from TR etc)? |
 |
|
|
Vaishu
Posting Yak Master
178 Posts |
Posted - 2008-01-08 : 12:06:17
|
Other values not necessary. If you let me know how to do for 1 value thats enough. Thanksquote: Originally posted by visakh16 And where do you get other values (RTR,TRT.. from TR etc)?
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-08 : 12:18:03
|
| Try this:-INSERT INTO tblB (Sol1,Sol2,..SELECT t.Col1,t.Col3,.....FROM(SELECT Col1,Col2,Col3,other values FROM tblAUNION ALLSELECT Col1,Col2+'67' AS 'Col2',(Col3*2) AS 'Col3',other values from tblA)tORDER BY t.Col1Make sure that both select statement inside contains equal columns with corresponding columns being of same type. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2008-01-08 : 15:04:08
|
Something like this?INSERT Table2 ( Sol1, Sol2, Sol3, Sol4, Sol5 )SELECT Table1.Col1, Table1.Col2, Foo.Num, Table1.Col4, Table1.Col5FROM Table1 CROSS JOIN ( SELECT 32 AS Num UNION ALL SELECT 64 ) AS Foo |
 |
|
|
|