Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/lsp4you/public_html/connect.php on line 2
INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
If adding values for all the columns of the table, no need to specify the column names in the SQL query. However, the order of the values are in the same order as the columns in the table. The INSERT INTO syntax would be as follows:
INSERT INTO table_name VALUES (value1, value2, value3, ...); Remarks:
mysql> insert into department (dept_id, dept_name, location) -> values('D01', 'Computer', 'South Block'); Query OK, 1 row affected (0.12 sec) mysql> insert into department (dept_id, dept_name, location) -> values('D02', 'Commerce', 'E K Block'); Query OK, 1 row affected (0.08 sec) mysql> insert into department -> values('D03', 'Administration', 'E K Block Wing-1'); Query OK, 1 row affected (0.07 sec) mysql> insert into department -> values('D04', 'Psychology', 'E K Block Wing-3'); Query OK, 1 row affected (0.08 sec) mysql> insert into department (dept_id, dept_name) -> values('D05', 'Electronics'); Query OK, 1 row affected (0.09 sec) mysql> insert into department -> values('D06', 'Biosciences', 'Main Block'); Query OK, 1 row affected (0.08 sec) mysql>
mysql> select * from department; +---------+----------------+------------------+ | dept_id | dept_name | location | +---------+----------------+------------------+ | D01 | Computer | South Block | | D02 | Commerce | E K Block Wing-2 | | D03 | Administration | E K Block Wing-1 | | D04 | Psychology | E K Block Wing-3 | | D05 | Electronics | NULL | | D06 | Biosciences | Main Block | +---------+----------------+------------------+ 6 rows in set (0.01 sec) mysql>