Google News
logo
MariaDB - Interview Questions
How to insert records in a table in MariaDB database?
INSERT INTO statement is used to insert records in a table in the MariaDB database.
 
Syntax :
INSERT INTO tablename (field, field2,...) VALUES (value, value2,...);     
Or
INSERT INTO     
(column1, column2,... )    
VALUES    
(expression1, expression2, ... ),    
(expression1, expression2, ... ),    
 ...; ​
Or you can use it also with WHERE condition
INSERT INTO table    
(column1, column2, ... )    
SELECT expression1, expression2, ...    
FROM source_table    
[WHERE conditions]; 
For example
 
Specify the column name :
INSERT INTO person (first_name, last_name) VALUES ('Mohd', 'Pervez');  
Insert more than 1 row at a time :
INSERT INTO abc VALUES (1,"row 1"), (2, "row 2");  
Select from another table :
INSERT INTO abc SELECT * FROM person WHERE status= 'c'; 
Advertisement