why not we cant insert multiple rows different value in same column(single column)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why not we cant insert multiple rows different value in same column(single column)?

let say i have a table emp(eid,ename,sal,degn). emp table is created with 5 rows of value is inserted. now i add a new column in tht table (address). why cant i use different address name add in that column at a time.why i have to input single row thn another using where clause.

8th Nov 2016, 5:25 PM
Pradeep Singh
Pradeep Singh - avatar
9 Answers
0
Hey there, Pradeep. I am not sure I understand what you are asking. 1) You have a table with 4 columns which is filled with 5 records. 2) Then you add an extra column to the table. 3) You would like some way to define different values of the new column for each record (rather than, say, one default value everywhere) but without having to do five different update commands. Is this what you wanted? If it is then what you are asking is possible, say if you have another table with t_add(eid, address) and you do update emp, t_add set emp.address=t_add.address where emp.eid=t_add.eid How is that? Would that work for you?
8th Nov 2016, 7:31 PM
Giulio Pellitta
Giulio Pellitta - avatar
0
but still single row entry.i want multiple row with different value in one line commant for insertion.
8th Nov 2016, 7:46 PM
Pradeep Singh
Pradeep Singh - avatar
0
Pradeep, you cannot "insert" values only in certain column. Insert create whole new records, while update is used to set columns of existing records. Do you want to add extra rows or modify the existing ones?
8th Nov 2016, 7:51 PM
Giulio Pellitta
Giulio Pellitta - avatar
0
in update command i can add 5 value to new adress column by set the value 5 time by where condition.but can i add at one time all 5 rows in address column.
8th Nov 2016, 7:56 PM
Pradeep Singh
Pradeep Singh - avatar
0
I am not sure what you mean. You only need a single update command to set the values of the last column (all at one time) if you do something like what I showed you. Of course you can also do it with five update commands.
8th Nov 2016, 9:56 PM
Giulio Pellitta
Giulio Pellitta - avatar
0
if i add a multiple rows in a single column with existing table thn the all value are same.so i have update all 5 rows one by one.what u answer in the 1st post can i do multiple row entry in that particular colimn only.existing table without adding any other column value or affecting thm.
9th Nov 2016, 3:12 AM
Pradeep Singh
Pradeep Singh - avatar
0
Can you post what you have done so far?
9th Nov 2016, 6:49 AM
Giulio Pellitta
Giulio Pellitta - avatar
0
table emp is created with 4 column eid,ename,s al,degn. values of 5 row is done. now i add new column by alter command. in adding of value in that column(address) i use update emp set address=india where eid=1; 1row inserted update emp set adress=usa where eid=2; 1 row inserted likewise i have to do 5 times. i want to do in single time command to do that address column with row value are different like(india in row1 of column address. usa in row2 of column address respectively in single comand.now u understand..plz reply
9th Nov 2016, 7:07 AM
Pradeep Singh
Pradeep Singh - avatar
0
I am starting to wonder, is it just something you are trying to understand or is it actually a problem you need to solve? Can you explain where do the address come from? Do you have another table somewhere? If you can at least put them in a table in the same order as the matching records you might be able to add them with a single command. Some databases (e.g. Oracle) have an implicit field called row_num or rownum or something like that. You can use this field to do an update using in the where clause that the two fields of the two tables are equal.
9th Nov 2016, 9:11 PM
Giulio Pellitta
Giulio Pellitta - avatar