|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Insert the same value into multiple rows?
I've got a whole bunch of rows to create, each with a unique key.
Each row gets the same value ("New") set in the "Age" column. I've seen the INSERT INTO table (rows,) VALUES (val for row1), (val for row2), etc. But what if each row gets the same exact value? How should I do that? Thanks |
|
#2
|
|||
|
|||
|
When you are doing an INSERT INTO, a new record is to be created. So, AFAIK, you will have to do the INSERT INTO table (col1) VALUES (val1), (val2) ; , doesn't matter if the values are same or different.
__________________
What you get is either what you desired or what you deserved. Death seems to be such an abominable thing, but do we really want to live for ever? |
|
#3
|
|||
|
|||
|
But doesn't this seem like a simple thing that should be available already?
|
|
#4
|
||||
|
||||
|
So you are inserting a new player perhaps and their character age is new and then might change to something else later? then why not set the default for that column to 'new' you then don't have to populate that column it will automatically get set to new when you insert your other columns.
__________________
MySQL - reformat varchar dates to proper date type || MySQL - room vacancies || output results with column names with mysql only Latest row per group || Deleting duplicates || Gaps in auto increment column My site: sql help articles |
|
#5
|
|||
|
|||
|
That's a good workaround, Guelphdad. Thanks
![]() |
|
#6
|
||||
|
||||
|
it isn't a workaround, it is the approach you should be using.
|
![]() |
| Viewing: Dev Shed Forums > Databases > MySQL Help > Insert the same value into multiple rows? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|