Translate

Showing posts with label sql 18. Show all posts
Showing posts with label sql 18. Show all posts

Friday, 17 September 2021

Select and distinct statements in sql videos in Telugu 18

 https://youtu.be/G7V0lnEkD84

------------------------------------
| hyderabad | mounika |
| jntu      | revathi |
| gutta     | anji    |
| lb nagar  | harika  |
| jntu      | praveen |
| munipeda  | pandu   |
| pune      | pandu   |
+-----------+---------+
9 rows in set (0.011 sec)

MariaDB [vlrinst]> INSERT INTO emp(name, loc, age,sal)
    -> VALUES ('venkat', 'kphb', 35,30000),
    ->        ('praveen', 'pune', 28,35000),
    ->        ('mounika', 'hyderabad', 22,39000),
    ->        ('revathi', 'jntu', 26,20000),
    ->        ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 5
MariaDB [vlrinst]> INSERT INTO emp(name, loc, age,sal)
    -> VALUES ('venkat', 'kphb', 35,30000),
    ->        ('praveen', 'pune', 28,35000),
    ->        ('mounika', 'hyderabad', 22,39000),
    ->        ('revathi', 'jntu', 26,20000),
    -> INSERT INTO emp(name, loc, age,sal)
    -> VALUES ('venkat', 'kphb', 35,30000),
    ->        ('praveen', 'pune', 28,35000),
    ->        ('mounika', 'hyderabad', 22,39000),
    ->        ('revathi', 'jntu', 26,20000)
    ->        ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO emp(name, loc, age,sa
l)
VALUES ('venkat', 'kphb', 35,30000),
   ...' at line 6
MariaDB [vlrinst]> INSERT INTO emp(name, loc, age,sal)
    -> VALUES ('venkat', 'kphb', 35,30000),
    ->        ('praveen', 'pune', 28,35000),
    ->        ('mounika', 'hyderabad', 22,39000),
    ->        ('revathi', 'jntu', 26,20000)
    ->        ;
Query OK, 4 rows affected (0.105 sec)
Records: 4  Duplicates: 0  Warnings: 0

MariaDB [vlrinst]> select * from emp
    -> ;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
|  1 | venkat  | kphb      |   35 | 30000 |
|  2 | praveen | pune      |   28 | 35000 |
|  3 | mounika | hyderabad |   22 | 39000 |
|  4 | revathi | jntu      |   26 | 20000 |
|  5 | anji    | gutta     |   28 | 20000 |
|  6 | harika  | lb nagar  |   26 | 30100 |
|  7 | praveen | jntu      |   33 |   100 |
|  8 | pandu   | munipeda  |   35 | 30300 |
|  9 | pandu   | pune      |   23 | 39300 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
+----+---------+-----------+------+-------+
13 rows in set (0.001 sec)

MariaDB [vlrinst]> select distinct loc,name form emp;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'emp' at line 1
MariaDB [vlrinst]> select distinct loc,name from emp;
+-----------+---------+
| loc       | name    |
+-----------+---------+
| kphb      | venkat  |
| pune      | praveen |
| hyderabad | mounika |
| jntu      | revathi |
| gutta     | anji    |
| lb nagar  | harika  |
| jntu      | praveen |
| munipeda  | pandu   |
| pune      | pandu   |
+-----------+---------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select distinct loc,name,id from emp;
+-----------+---------+----+
| loc       | name    | id |
+-----------+---------+----+
| kphb      | venkat  |  1 |
| pune      | praveen |  2 |
| hyderabad | mounika |  3 |
| jntu      | revathi |  4 |
| gutta     | anji    |  5 |
| lb nagar  | harika  |  6 |
| jntu      | praveen |  7 |
| munipeda  | pandu   |  8 |
| pune      | pandu   |  9 |
| kphb      | venkat  | 10 |
| pune      | praveen | 11 |
| hyderabad | mounika | 12 |
| jntu      | revathi | 13 |
+-----------+---------+----+
13 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
|  1 | venkat  | kphb      |   35 | 30000 |
|  2 | praveen | pune      |   28 | 35000 |
|  3 | mounika | hyderabad |   22 | 39000 |
|  4 | revathi | jntu      |   26 | 20000 |
|  5 | anji    | gutta     |   28 | 20000 |
|  6 | harika  | lb nagar  |   26 | 30100 |
|  7 | praveen | jntu      |   33 |   100 |
|  8 | pandu   | munipeda  |   35 | 30300 |
|  9 | pandu   | pune      |   23 | 39300 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
+----+---------+-----------+------+-------+
13 rows in set (0.001 sec)

MariaDB [vlrinst]> select id,name from emp where sal>30000;
+----+---------+
| id | name    |
+----+---------+
|  2 | praveen |
|  3 | mounika |
|  6 | harika  |
|  8 | pandu   |
|  9 | pandu   |
| 11 | praveen |
| 12 | mounika |
+----+---------+
7 rows in set (0.074 sec)

MariaDB [vlrinst]> select id,name from emp where loc = 'pune';
+----+---------+
| id | name    |
+----+---------+
|  2 | praveen |
|  9 | pandu   |
| 11 | praveen |
+----+---------+
3 rows in set (0.129 sec)

MariaDB [vlrinst]> select id,name from emp where name <> 'praveen';
+----+---------+
| id | name    |
+----+---------+
|  1 | venkat  |
|  3 | mounika |
|  4 | revathi |
|  5 | anji    |
|  6 | harika  |
|  8 | pandu   |
|  9 | pandu   |
| 10 | venkat  |
| 12 | mounika |
| 13 | revathi |
+----+---------+
10 rows in set (0.001 sec)

MariaDB [vlrinst]> select id,name from emp where name <> 'Praveen';
+----+---------+
| id | name    |
+----+---------+
|  1 | venkat  |
|  3 | mounika |
|  4 | revathi |
|  5 | anji    |
|  6 | harika  |
|  8 | pandu   |
|  9 | pandu   |
| 10 | venkat  |
| 12 | mounika |
| 13 | revathi |
+----+---------+
10 rows in set (0.001 sec)

MariaDB [vlrinst]> select id,name from emp where sal between 30000 and 35000;
+----+---------+
| id | name    |
+----+---------+
|  1 | venkat  |
|  2 | praveen |
|  6 | harika  |
|  8 | pandu   |
| 10 | venkat  |
| 11 | praveen |
+----+---------+
6 rows in set (0.045 sec)

MariaDB [vlrinst]> select id,name from emp where sal between 30000 and 32000;
+----+--------+
| id | name   |
+----+--------+
|  1 | venkat |
|  6 | harika |
|  8 | pandu  |
| 10 | venkat |
+----+--------+
4 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal from emp where sal between 30000 and 32000;
+----+--------+-------+
| id | name   | sal   |
+----+--------+-------+
|  1 | venkat | 30000 |
|  6 | harika | 30100 |
|  8 | pandu  | 30300 |
| 10 | venkat | 30000 |
+----+--------+-------+
4 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal from emp where name like 'h%';
+----+--------+-------+
| id | name   | sal   |
+----+--------+-------+
|  6 | harika | 30100 |
+----+--------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select id,name,sal from emp where name like 'r%';
+----+---------+-------+
| id | name    | sal   |
+----+---------+-------+
|  4 | revathi | 20000 |
| 13 | revathi | 20000 |
+----+---------+-------+
2 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal from emp where name like '%r';
Empty set (0.001 sec)

MariaDB [vlrinst]> select id,name,sal from emp where name like '%n';
+----+---------+-------+
| id | name    | sal   |
+----+---------+-------+
|  2 | praveen | 35000 |
|  7 | praveen |   100 |
| 11 | praveen | 35000 |
+----+---------+-------+
3 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal from emp where loc in('pune','jntu');
+----+---------+-------+
| id | name    | sal   |
+----+---------+-------+
|  2 | praveen | 35000 |
|  4 | revathi | 20000 |
|  7 | praveen |   100 |
|  9 | pandu   | 39300 |
| 11 | praveen | 35000 |
| 13 | revathi | 20000 |
+----+---------+-------+
6 rows in set (0.031 sec)

MariaDB [vlrinst]> select id,name,sal,loc from emp where loc in('pune','jntu');
+----+---------+-------+------+
| id | name    | sal   | loc  |
+----+---------+-------+------+
|  2 | praveen | 35000 | pune |
|  4 | revathi | 20000 | jntu |
|  7 | praveen |   100 | jntu |
|  9 | pandu   | 39300 | pune |
| 11 | praveen | 35000 | pune |
| 13 | revathi | 20000 | jntu |
+----+---------+-------+------+
6 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal,loc from emp where loc in('pune','jntu','kphb');
+----+---------+-------+------+
| id | name    | sal   | loc  |
+----+---------+-------+------+
|  1 | venkat  | 30000 | kphb |
|  2 | praveen | 35000 | pune |
|  4 | revathi | 20000 | jntu |
|  7 | praveen |   100 | jntu |
|  9 | pandu   | 39300 | pune |
| 10 | venkat  | 30000 | kphb |
| 11 | praveen | 35000 | pune |
| 13 | revathi | 20000 | jntu |
+----+---------+-------+------+
8 rows in set (0.000 sec)

MariaDB [vlrinst]> select id,name,sal,loc from emp where loc in('pune','jntu','kphb','sjks');
+----+---------+-------+------+
| id | name    | sal   | loc  |
+----+---------+-------+------+
|  1 | venkat  | 30000 | kphb |
|  2 | praveen | 35000 | pune |
|  4 | revathi | 20000 | jntu |
|  7 | praveen |   100 | jntu |
|  9 | pandu   | 39300 | pune |
| 10 | venkat  | 30000 | kphb |
| 11 | praveen | 35000 | pune |
| 13 | revathi | 20000 | jntu |
+----+---------+-------+------+
8 rows in set (0.001 sec)

MariaDB [vlrinst]>