This document shows the usage of MySQL commands to create and manage databases, tables, insert and update data. It creates databases and tables, adds and modifies columns, inserts sample data, runs queries to retrieve, aggregate and filter data.
This document shows the usage of MySQL commands to create and manage databases, tables, insert and update data. It creates databases and tables, adds and modifies columns, inserts sample data, runs queries to retrieve, aggregate and filter data.
This document shows the usage of MySQL commands to create and manage databases, tables, insert and update data. It creates databases and tables, adds and modifies columns, inserts sample data, runs queries to retrieve, aggregate and filter data.
This document shows the usage of MySQL commands to create and manage databases, tables, insert and update data. It creates databases and tables, adds and modifies columns, inserts sample data, runs queries to retrieve, aggregate and filter data.
mysql> insert into order values(1,'dell',1),(2,'iphone',2),(3,'hp',2),
(4,'lenevo',3); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order values(1,'dell',1),(2,'iphone',2),(3,'hp',2),(4,'lenevo',3)' at line 1 mysql> insert into order(oid,oname,pid)values(1,'dell',1),(2,'iphone',2), (3,'hp',2),(4,'lenevo',3); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order(oid,oname,pid)values(1,'dell',1),(2,'iphone',2),(3,'hp',2),(4,'lenevo',3)' at line 1 mysql> insert into orders values(1,'dell',1),(2,'iphone',2),(3,'hp',2), (4,'lenevo',3); Query OK, 4 rows affected (0.01 sec) Records: 4 Duplicates: 0 Warnings: 0
+-----+--------+-----+ | pid | name | age | +-----+--------+-----+ | 1 | shital | 20 | | 2 | vrush | 20 | | 3 | palak | 23 | | 4 | vaishi | 18 | | 5 | anya | 28 | | 6 | nik | 28 | +-----+--------+-----+ 6 rows in set (0.00 sec) mysql> select count(age) from personn where age>18; +------------+ | count(age) | +------------+ | 5 | +------------+ 1 row in set (0.00 sec)
mysql> select count(age) from personn where age>21;
+------------+ | count(age) | +------------+ | 3 | +------------+ 1 row in set (0.00 sec)
mysql> select count(name) from personn where name like ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 mysql> select count(name) from personn where name like '%l'; +-------------+ | count(name) | +-------------+ | 1 | +-------------+ 1 row in set (0.00 sec)
mysql> select min(age) from personn;
+----------+ | min(age) | +----------+ | 18 | +----------+ 1 row in set (0.00 sec)
mysql> select max(age) from personn;
+----------+ | max(age) | +----------+ | 28 | +----------+ 1 row in set (0.00 sec)
mysql> select avg(age) from personn;
+----------+ | avg(age) | +----------+ | 22.8333 | +----------+ 1 row in set (0.00 sec)
mysql> select count(distinct name) from personn;
+----------------------+ | count(distinct name) | +----------------------+ | 6 | +----------------------+ 1 row in set (0.00 sec) mysql> select count(distinct age) from personn; +---------------------+ | count(distinct age) | +---------------------+ | 4 | +---------------------+ 1 row in set (0.00 sec)