Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Insert + Select + Values
Fri, Jun 20 2008 4:58 AMPermanent Link

Dave
Hi

I want to insert values into a table from another table AND a constant.  

E.g.

Table1 has fields:

Name
Country
Status

My SQL is:

Insert Into Table 1
(Name,Country,Status)
SELECT Name,Country FROM Table2

But for each inserted row i also want to set the Status to say "3"

I can't do a second pass because there might already be Status "1", Status "2", etc in the
table (from previous tasks).


Apologies for my poor knowledge of SQL.

Dave
Fri, Jun 20 2008 5:10 AMPermanent Link

Dave
Sorry, I researched some more and see that this is valid in DBISAM:

Insert Into Table 1
(Status,Name,Country)
SELECT 3,Name,Country FROM Table2

Whereas this does not work (prior to EDB):

Insert Into Table 1
(Status,Name,Country)
Values
(3,
(SELECT Name,Country FROM Table2)
)
Fri, Jun 20 2008 5:11 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Dave,

> I want to insert values into a table from another table AND a constant.

You can do it as follows:
INSERT INTO Table1 (Name,Country,Status) SELECT Name, Country, 3 FROM Table2

--
Fernando Dias
[Team Elevate]

Fri, Jun 20 2008 5:24 AMPermanent Link

Fernando Dias

Team Elevate Team Elevate

Dave,

> Whereas this does not work (prior to EDB):

That will not work in EDB too.

--
Fernando Dias
[Team Elevate]

Image