This is a discussion on insert constant with list from select within the MySQL Database forums, part of the Database Forums category; Hi I am trying to insert into a table a bunch of rows from a select and a constant. I ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi
I am trying to insert into a table a bunch of rows from a select and a constant. I tried this which seems like it should work: INSERT INTO workgroupUsers VALUES( SELECT 280, username FROM workgroupUsers WHERE id = 278); is this because I am selecting from the same table I am updating? or is it not possible to achieve what I am trying Mike Cardeiro |
|
|||
|
On 26 Feb, 16:49, "mcarde...@yahoo.com" <mcarde...@yahoo.com> wrote:
> Hi > > I am trying to insert into a table a bunch of rows from a select and a > constant. I tried this which seems like it should work: > > INSERT INTO workgroupUsers VALUES( SELECT 280, username FROM > workgroupUsers WHERE id = 278); > > is this because I am selecting from the same table I am updating? or > is it not possible to achieve what I am trying > > Mike Cardeiro You need to use the INSERT SELECT syntax as specified in the manual. You can't just make up your own syntax. |
|
|||
|
On Feb 26, 8:49 am, "mcarde...@yahoo.com" <mcarde...@yahoo.com> wrote:
> Hi > > I am trying to insert into a table a bunch of rows from a select and a > constant. I tried this which seems like it should work: > > INSERT INTO workgroupUsers VALUES( SELECT 280, username FROM > workgroupUsers WHERE id = 278); > INSERT INTO workgroupUsers (id, username) SELECT 280, username FROM workgroupUsers WHERE id = 278 And - - - follow Captain Paralytic's sound advice |
![]() |
| Thread Tools | |
| Display Modes | |
|
|