Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERT with SELECT in mySQL

Status
Not open for further replies.

boolean

Programmer
Mar 5, 2002
35
US
Hey pals...

Why wouldn't this query work in MySQL?:

INSERT INTO PAGE
(
PAGE_ID,
PAGE_NAME,
PAGE_LOCATION
)
SELECT 2,
PAGE_NAME,
PAGE_LOCATION
FROM PAGE WHERE PAGE_ID=1;

I just want to replicate the records for PAGE_ID=1... If this wouldn;t work, can anyone gimme a work around please....
FYI, i am using MySQL 4.0.12 Sham aka boolean... be practical/be straight... true/false?!
 
This is a shortcoming in Mysql. You need to do it in two steps, first select the values into variables and then do an insert.
 
thanks boogie...

well... i have not really worked on Mysql as much as the other drivers... why dont you tell me how to go about it? and FYI the apps using inline queries... can the 2 steps done together in 1 query??
Sham aka boolean... be practical/be straight... true/false?!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top