From: Francis Baiden on 12 Jul 2010 04:11 Hi guys, After seeing the benefits one can derived in developing applications running on sql, I have tried my hands on some small application, but with some challenges, and I will be grateful if someone can help me out. I want the contents one table to be added to some specific fields in another table. for eg. Table 1 P_Id pMonth pYear pRegistrar pFormType pCasetype ..... table 2 fID FormName 1 Land 2 Commercial 3 Defamation .... ..... I want to insert the values of table 2 to table 1 specifically the P_Id and Casetype and line with some global variables glo:Month = "July"; glo:Year = 2010; glo:registrar = "Rexford Gyimah" ; glo:rform = "Form A". I want the result table to look like this after the insert P_Id pMonth pYear pRegistrar pFormType pCasetype 1 July 2010 Rexford Gyimah Form A Land 2 July 2010 Rexford Gyimah Form A Commercial 3 July 2010 Rexford Gyimah Form A Defamation Can any help me with the right syntax for such an operation. This is one of my challenges in this application am working on. Thank you. Francis
From: John Bell on 13 Jul 2010 02:29 On Mon, 12 Jul 2010 08:11:57 -0000, "Francis Baiden" <joebaiden1(a)yahoo.com> wrote: >Hi guys, > >After seeing the benefits one can derived in developing applications running >on sql, I have tried my hands on some small >application, but with some challenges, and I will be grateful if someone can >help me out. > >I want the contents one table to be added to some specific fields in another >table. for eg. > >Table 1 > >P_Id pMonth pYear pRegistrar pFormType >pCasetype ..... > > > >table 2 >fID FormName >1 Land >2 Commercial >3 Defamation >... ..... > >I want to insert the values of table 2 to table 1 specifically the P_Id and >Casetype and line with some global variables glo:Month = "July"; glo:Year = >2010; glo:registrar = "Rexford Gyimah" ; glo:rform = "Form A". > >I want the result table to look like this after the insert > >P_Id pMonth pYear pRegistrar pFormType >pCasetype >1 July 2010 Rexford Gyimah Form A >Land >2 July 2010 Rexford Gyimah Form A >Commercial >3 July 2010 Rexford Gyimah Form A >Defamation > >Can any help me with the right syntax for such an operation. This is one of >my challenges in this application am working on. > >Thank you. > >Francis > Hi It is not that clear what you are trying to do, if you posted DDL and example data as insert statements it would be less ambiguous and give people something to go on. See http://www.aspfaq.com/etiquette.asp?id=5006 How do you match rows in table1 and table2 ? John
From: Philipp Post on 14 Jul 2010 08:02 > I want to insert the values of table 2 to table 1 specifically the P_Id and > Casetype and line with some global variables glo:Month = "July"; glo:Year = > 2010; glo:registrar = "Rexford Gyimah" ; glo:rform = "Form A". Like this? INSERT INTO Table_1(P_Id, pMonth, pYear, pRegistrar, pFormType, pCasetype) SELECT P_Id, 'July' AS pMonth, 2010 AS pYear, 'Rexford Gyimah' AS pRegistrar, 'Form A' AS pFormType, pCasetype FROM Table_2 WHERE [insert conditions here] brgds Philipp Post
|
Pages: 1 Prev: Free Text Search issue ?! Next: error when trying to alter table in transaction |