List:General Discussion« Previous MessageNext Message »
From:Ed Reed Date:August 30 2005 9:37pm
Subject:Re: Insert Into problem
View as plain text  
Thanks guys!
 


>>> SGreen@stripped> 8/30/05 1:22 PM >>


The correct syntax for the second method doesn't use "VALUES()". I would always use this
form if I were going to exclude any columns from receiving data. It's just safer and
relies less on the SQL engine to correctly divine what it is you want to do. 

Insert Into tbl1 (fld1, fld2, fld3, fld4)
Select 10306, fld2, fld3, fld4 From tbl1 Where fld1=8114; 

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
 
>>> "Eamon Daly" <edaly@stripped> 8/30/05 1:25 PM >>>
Drop the VALUES part in your second attempt:

INSERT INTO tbl1 (fld1, fld2, fld3, fld4)
SELECT 10306, fld2, fld3, fld4
FROM tbl1
WHERE fld1 = 8114

Note that you'll need to be running MySQL 4.0.14 or above to
insert into the same table you're selecting from.

____________________________________________________________
Eamon Daly



Thread
Insert Into problemEd Reed30 Aug
  • Re: Insert Into problemEamon Daly30 Aug
  • Re: Insert Into problemSGreen30 Aug
Re: Insert Into problemEd Reed30 Aug