Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert data in only few column leaving other columns empty or as they are in a mysql table record?

I have created a table named 'students'. It has following fields :

 roll_no <- type:Integer Not Null,
 course_name <- type:varchar(40) Not Null,     
 std_surname <- type:varchar(40) Not Null,
 std_firstname <- type:varchar(40) Not Null,      
 emailid <- type:varchar(40) ,   
 address <- type:varchar(40) Not Null,
 income <- type:Integer,        
 gender <- type:varchar(10) Not Null,         
 experience <- type:Integer, 

in the above fields mentioned some accept null values and most of them don't accept null values or null values are not allowed.

What I want to do is I want to insert some information or data into the columns that do not accept null values and then I want to insert remaining data into the remaining columns later. How can I achieve this?

More specifically how can I insert only few data into specific fields in a record at a time using insert query leaving other fields empty and then insert remaining field values like email or experience ???

Please help me with this problem?

like image 979
Abhijit Avatar asked Mar 13 '23 05:03

Abhijit


1 Answers

Insert into selected fields

for ex

    INSERT INTO 
            students
            (roll_no, course_name, dob, gender)
    VALUES
            (111, 'MBA', '1991-01-01', 'F');

for inserting NULL values, have a look at

Insert NULL value into INT column

like image 153
Hytool Avatar answered Mar 15 '23 09:03

Hytool