0 votes
in MariaDB by
How to insert records in a table in MariaDB database?

1 Answer

0 votes
by
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

1.  INSERT INTO     

2.  (column1, column2,... )    

3.  VALUES    

4.  (expression1, expression2, ... ),    

5.  (expression1, expression2, ... ),    

6.  ...;     

Or you can use it also with WHERE condition

1.  INSERT INTO table    

2.  (column1, column2, ... )    

3.  SELECT expression1, expression2, ...    

4.  FROM source_table    

5.  [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';
...