Translate

Friday, 1 October 2021

SQL LIKE Operator sql videos in telugu 34

 https://youtu.be/y819yZjdSfA

---------------------------------------
The COUNT() function is an aggregate function that returns the number of rows in a table. The COUNT() function allows you to count all rows or only rows that match a specified condition.


The COUNT() function has three forms: COUNT(*), COUNT(expression) and COUNT(DISTINCT expression).

COUNT(*) function
The COUNT(*) function returns the number of rows in a result set returned by a SELECT statement. The COUNT(*) returns the number of rows including duplicate, non-NULL and NULL rows.

SELECT COUNT(*) FROM emp;


COUNT(expression)
The COUNT(expression) returns the number of rows that do not contain NULL values as the result of the expression.
SELECT COUNT(name) FROM emp;


COUNT(DISTINCT expression)
The COUNT(DISTINCT expression) returns the number of distinct rows that do not contain NULL values as the result of the expression.
SELECT COUNT(DISTINCT name) FROM emp;
SELECT COUNT(DISTINCT name,sal) FROM emp;


The return type of the COUNT() function is BIGINT. The COUNT()  function returns 0 if there is no matching row found.

SELECT COUNT(*) FROM emp WHERE name LIKE '%the%';
---------------

Setting environment for using XAMPP for Windows.
Mounika@MOUNIKA-PC c:\xampp
# ram.cmd
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.18-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use vlrinst;
Database changed
MariaDB [vlrinst]> select * from emp;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 16 | praveen | jntu      |   33 |   100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
+----+---------+-----------+------+-------+
9 rows in set (0.112 sec)

MariaDB [vlrinst]> select count(*) from emp;
+----------+
| count(*) |
+----------+
|        9 |
+----------+
1 row in set (0.051 sec)

MariaDB [vlrinst]> select count(loc) from emp;
+------------+
| count(loc) |
+------------+
|          9 |
+------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(name) from emp;
+-------------+
| count(name) |
+-------------+
|           9 |
+-------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(distinct name) from emp;
+----------------------+
| count(distinct name) |
+----------------------+
|                    7 |
+----------------------+
1 row in set (0.045 sec)

MariaDB [vlrinst]> select count(distinct name,sal) from emp;
+--------------------------+
| count(distinct name,sal) |
+--------------------------+
|                        9 |
+--------------------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(distinct name,loc) from emp;
+--------------------------+
| count(distinct name,loc) |
+--------------------------+
|                        9 |
+--------------------------+
1 row in set (0.001 sec)

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

MariaDB [vlrinst]> insert into emp values("pandu","pune",18,50000);
ERROR 1136 (21S01): Column count doesn't match value count at row 1
MariaDB [vlrinst]> insert into emp values(17,"pandu","pune",18,50000);
ERROR 1062 (23000): Duplicate entry '17' for key 'PRIMARY'
MariaDB [vlrinst]> insert into emp values(27,"pandu","pune",18,50000);
Query OK, 1 row affected (0.117 sec)

MariaDB [vlrinst]> select * from emp;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 16 | praveen | jntu      |   33 |   100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
| 27 | pandu   | pune      |   18 | 50000 |
+----+---------+-----------+------+-------+
10 rows in set (0.001 sec)

MariaDB [vlrinst]> select count(distinct name,loc) from emp;
+--------------------------+
| count(distinct name,loc) |
+--------------------------+
|                        9 |
+--------------------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(*) from emp where like "%i%";
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 'like "%i%"' at line 1
MariaDB [vlrinst]> select count(*) from emp where name like "%i%";
+----------+
| count(*) |
+----------+
|        4 |
+----------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(*) from emp where name like "kphb";
+----------+
| count(*) |
+----------+
|        0 |
+----------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(*) from emp where loc like "kphb";
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select count(*) from emp where loc = "kphb";
+----------+
| count(*) |
+----------+
|        1 |
+----------+
1 row in set (0.002 sec)

MariaDB [vlrinst]> select count(*) from emp where age >30;
+----------+
| count(*) |
+----------+
|        3 |
+----------+
1 row in set (0.038 sec)

MariaDB [vlrinst]>

Limit keyword sql videos in telugu 33

 https://youtu.be/kSR1Ce-f7Hc

------------------------------------------
The SQL LIKE Operator
The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

There are two wildcards often used in conjunction with the LIKE operator:

 The percent sign (%) represents zero, one, or multiple characters
 
The underscore sign (_) represents one, single character

Note: MS Access uses an asterisk (*) instead of the percent sign (%), and a question mark (?) instead of the underscore (_).



The percent sign and the underscore can also be used in combinations!

LIKE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE columnN LIKE pattern;

---------
You can also combine any number of conditions using AND or OR operators.

Here are some examples showing different LIKE operators with '%' and '_' wildcards:
--------------------


LIKE Operator Description

WHERE CustomerName LIKE 'a%' Finds any values that start with "a"

WHERE CustomerName LIKE '%a' Finds any values that end with "a"

WHERE CustomerName LIKE '%or%' Finds any values that have "or" in any position

WHERE CustomerName LIKE '_r%' Finds any values that have "r" in the second position

WHERE CustomerName LIKE 'a_%' Finds any values that start with "a" and are at least 2 characters in length

WHERE CustomerName LIKE 'a__%' Finds any values that start with "a" and are at least 3 characters in length

WHERE ContactName LIKE 'a%o' Finds any values that start with "a" and ends with "o"

---------------
33 SQL LIKE Operator sql videos in telugu

Setting environment for using XAMPP for Windows.
Mounika@MOUNIKA-PC c:\xampp
# ram.cmd
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.18-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use vlrinst;
Database changed
MariaDB [vlrinst]> select * from emp where name like 'r%';
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 13 | revathi | jntu |   26 | 20000 |
+----+---------+------+------+-------+
1 row in set (0.001 sec)

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

MariaDB [vlrinst]> select * from emp where name like '%t';
+----+--------+------+------+-------+
| id | name   | loc  | age  | sal   |
+----+--------+------+------+-------+
| 10 | venkat | kphb |   35 | 30000 |
+----+--------+------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '%t%';
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 10 | venkat  | kphb |   35 | 30000 |
| 13 | revathi | jntu |   26 | 20000 |
+----+---------+------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '%ra%';
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 11 | praveen | pune |   28 | 35000 |
| 16 | praveen | jntu |   33 |   100 |
+----+---------+------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like 'ra%';
Empty set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like 'r%';
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 13 | revathi | jntu |   26 | 20000 |
+----+---------+------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '%nk%';
+----+--------+------+------+-------+
| id | name   | loc  | age  | sal   |
+----+--------+------+------+-------+
| 10 | venkat | kphb |   35 | 30000 |
+----+--------+------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like 'nk%';
Empty set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '%n%';
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 16 | praveen | jntu      |   33 |   100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
+----+---------+-----------+------+-------+
7 rows in set (0.002 sec)

MariaDB [vlrinst]> select * from emp where name like '__a%';
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 11 | praveen | pune |   28 | 35000 |
| 16 | praveen | jntu |   33 |   100 |
+----+---------+------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '__a';
Empty set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '____u';
+----+-------+----------+------+-------+
| id | name  | loc      | age  | sal   |
+----+-------+----------+------+-------+
| 17 | pandu | munipeda |   35 | 30300 |
| 18 | pandu | pune     |   23 | 39300 |
+----+-------+----------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where name like '_a%';
+----+--------+----------+------+-------+
| id | name   | loc      | age  | sal   |
+----+--------+----------+------+-------+
| 15 | harika | lb nagar |   26 | 30100 |
| 17 | pandu  | munipeda |   35 | 30300 |
| 18 | pandu  | pune     |   23 | 39300 |
+----+--------+----------+------+-------+
3 rows in set (0.002 sec)

MariaDB [vlrinst]> select * from emp where name like 'h%a';
+----+--------+----------+------+-------+
| id | name   | loc      | age  | sal   |
+----+--------+----------+------+-------+
| 15 | harika | lb nagar |   26 | 30100 |
+----+--------+----------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]>

ORDER BY keyword sql videos in telugu 32

 https://youtu.be/Vs4WkppaVyo

-----------------------------------------------
The LIMIT clause is used in the SELECT statement to constrain the number of rows to return. The LIMIT clause accepts one or two arguments. The values of both arguments must be zero or positive integers.

Setting environment for using XAMPP for Windows.
Mounika@MOUNIKA-PC c:\xampp
# ram.cmd
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.18-MariaDB mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use vlrinst;
Database changed
MariaDB [vlrinst]> select * from emp;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 16 | praveen | jntu      |   33 |   100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
+----+---------+-----------+------+-------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 1;
+----+--------+------+------+-------+
| id | name   | loc  | age  | sal   |
+----+--------+------+------+-------+
| 10 | venkat | kphb |   35 | 30000 |
+----+--------+------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 5;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
+----+---------+-----------+------+-------+
5 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 5,10;
+----+---------+----------+------+-------+
| id | name    | loc      | age  | sal   |
+----+---------+----------+------+-------+
| 15 | harika  | lb nagar |   26 | 30100 |
| 16 | praveen | jntu     |   33 |   100 |
| 17 | pandu   | munipeda |   35 | 30300 |
| 18 | pandu   | pune     |   23 | 39300 |
+----+---------+----------+------+-------+
4 rows in set (0.040 sec)

MariaDB [vlrinst]> select * from emp limit 3,7;
+----+---------+----------+------+-------+
| id | name    | loc      | age  | sal   |
+----+---------+----------+------+-------+
| 13 | revathi | jntu     |   26 | 20000 |
| 14 | anji    | gutta    |   28 | 20000 |
| 15 | harika  | lb nagar |   26 | 30100 |
| 16 | praveen | jntu     |   33 |   100 |
| 17 | pandu   | munipeda |   35 | 30300 |
| 18 | pandu   | pune     |   23 | 39300 |
+----+---------+----------+------+-------+
6 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 3,2;
+----+---------+-------+------+-------+
| id | name    | loc   | age  | sal   |
+----+---------+-------+------+-------+
| 13 | revathi | jntu  |   26 | 20000 |
| 14 | anji    | gutta |   28 | 20000 |
+----+---------+-------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 3,3;
+----+---------+----------+------+-------+
| id | name    | loc      | age  | sal   |
+----+---------+----------+------+-------+
| 13 | revathi | jntu     |   26 | 20000 |
| 14 | anji    | gutta    |   28 | 20000 |
| 15 | harika  | lb nagar |   26 | 30100 |
+----+---------+----------+------+-------+
3 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 1,7;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 16 | praveen | jntu      |   33 |   100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
+----+---------+-----------+------+-------+
7 rows in set (0.000 sec)

MariaDB [vlrinst]> select * from emp limit 1,4;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
+----+---------+-----------+------+-------+
4 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 4;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 10 | venkat  | kphb      |   35 | 30000 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 13 | revathi | jntu      |   26 | 20000 |
+----+---------+-----------+------+-------+
4 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp limit 3,4;
+----+---------+----------+------+-------+
| id | name    | loc      | age  | sal   |
+----+---------+----------+------+-------+
| 13 | revathi | jntu     |   26 | 20000 |
| 14 | anji    | gutta    |   28 | 20000 |
| 15 | harika  | lb nagar |   26 | 30100 |
| 16 | praveen | jntu     |   33 |   100 |
+----+---------+----------+------+-------+
4 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where loc="jntu";
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 13 | revathi | jntu |   26 | 20000 |
| 16 | praveen | jntu |   33 |   100 |
+----+---------+------+------+-------+
2 rows in set (0.048 sec)

MariaDB [vlrinst]> select * from emp where loc="jntu" limit 1;
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 13 | revathi | jntu |   26 | 20000 |
+----+---------+------+------+-------+
1 row in set (0.002 sec)

MariaDB [vlrinst]> select * from emp order by sal;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 16 | praveen | jntu      |   33 |   100 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 18 | pandu   | pune      |   23 | 39300 |
+----+---------+-----------+------+-------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp order by sal desc;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 18 | pandu   | pune      |   23 | 39300 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 11 | praveen | pune      |   28 | 35000 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 16 | praveen | jntu      |   33 |   100 |
+----+---------+-----------+------+-------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp order by sal desc limit 1;
+----+-------+------+------+-------+
| id | name  | loc  | age  | sal   |
+----+-------+------+------+-------+
| 18 | pandu | pune |   23 | 39300 |
+----+-------+------+------+-------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select * from emp order by sal desc limit 3;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 18 | pandu   | pune      |   23 | 39300 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 11 | praveen | pune      |   28 | 35000 |
+----+---------+-----------+------+-------+
3 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where loc="jntu";
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 13 | revathi | jntu |   26 | 20000 |
| 16 | praveen | jntu |   33 |   100 |
+----+---------+------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where loc="jntu" order by sal;
+----+---------+------+------+-------+
| id | name    | loc  | age  | sal   |
+----+---------+------+------+-------+
| 16 | praveen | jntu |   33 |   100 |
| 13 | revathi | jntu |   26 | 20000 |
+----+---------+------+------+-------+
2 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp where loc="jntu" order by sal limit 1;
+----+---------+------+------+------+
| id | name    | loc  | age  | sal  |
+----+---------+------+------+------+
| 16 | praveen | jntu |   33 |  100 |
+----+---------+------+------+------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select name from emp where loc="jntu" order by sal limit 1;
+---------+
| name    |
+---------+
| praveen |
+---------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select name,sal from emp where loc="jntu" order by sal limit 1;
+---------+------+
| name    | sal  |
+---------+------+
| praveen |  100 |
+---------+------+
1 row in set (0.001 sec)

MariaDB [vlrinst]>

REPLACE,REVERSE,RIGHT,SPACE,STRCMP,SUBSTRING INDEX,upper functions sql videos in telugu 31

 https://youtu.be/1bRFxL2bGqQ

-------------------------------------------
The SQL ORDER BY Keyword
The ORDER BY keyword is used to sort the result-set in ascending or descending order.

The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword.

ORDER BY Syntax
SELECT column1, column2, ...
FROM table_name
ORDER BY column1, column2, ... ASC|DESC;


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

MariaDB [vlrinst]> select * from emp order by name;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
| 11 | praveen | pune      |   28 | 35000 |
| 16 | praveen | jntu      |   33 |   100 |
| 13 | revathi | jntu      |   26 | 20000 |
| 10 | venkat  | kphb      |   35 | 30000 |
+----+---------+-----------+------+-------+
9 rows in set (0.038 sec)

MariaDB [vlrinst]> select * from emp order by sal;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 16 | praveen | jntu      |   33 |   100 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 11 | praveen | pune      |   28 | 35000 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 18 | pandu   | pune      |   23 | 39300 |
+----+---------+-----------+------+-------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp order by desc;
ERROR 1064 (42000): You have an error in your SQL synt
MariaDB [vlrinst]> select * from emp order by sal desc
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 18 | pandu   | pune      |   23 | 39300 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 11 | praveen | pune      |   28 | 35000 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 10 | venkat  | kphb      |   35 | 30000 |
| 13 | revathi | jntu      |   26 | 20000 |
| 14 | anji    | gutta     |   28 | 20000 |
| 16 | praveen | jntu      |   33 |   100 |
+----+---------+-----------+------+-------+
9 rows in set (0.000 sec)

MariaDB [vlrinst]> select name,loc from emp order by
ERROR 1064 (42000): You have an error in your SQL synt
MariaDB [vlrinst]> select name,loc from emp order by
    -> name,loc;
+---------+-----------+
| name    | loc       |
+---------+-----------+
| anji    | gutta     |
| harika  | lb nagar  |
| mounika | hyderabad |
| pandu   | munipeda  |
| pandu   | pune      |
| praveen | jntu      |
| praveen | pune      |
| revathi | jntu      |
| venkat  | kphb      |
+---------+-----------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select name,age,loc from emp
    -> order by 2;
+---------+------+-----------+
| name    | age  | loc       |
+---------+------+-----------+
| mounika |   22 | hyderabad |
| pandu   |   23 | pune      |
| revathi |   26 | jntu      |
| harika  |   26 | lb nagar  |
| praveen |   28 | pune      |
| anji    |   28 | gutta     |
| praveen |   33 | jntu      |
| venkat  |   35 | kphb      |
| pandu   |   35 | munipeda  |
+---------+------+-----------+
9 rows in set (0.024 sec)

MariaDB [vlrinst]> select name,age,loc from emp
    -> order by 2,1;
+---------+------+-----------+
| name    | age  | loc       |
+---------+------+-----------+
| mounika |   22 | hyderabad |
| pandu   |   23 | pune      |
| harika  |   26 | lb nagar  |
| revathi |   26 | jntu      |
| anji    |   28 | gutta     |
| praveen |   28 | pune      |
| praveen |   33 | jntu      |
| pandu   |   35 | munipeda  |
| venkat  |   35 | kphb      |
+---------+------+-----------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select * from emp order by 2;
+----+---------+-----------+------+-------+
| id | name    | loc       | age  | sal   |
+----+---------+-----------+------+-------+
| 14 | anji    | gutta     |   28 | 20000 |
| 15 | harika  | lb nagar  |   26 | 30100 |
| 12 | mounika | hyderabad |   22 | 39000 |
| 17 | pandu   | munipeda  |   35 | 30300 |
| 18 | pandu   | pune      |   23 | 39300 |
| 11 | praveen | pune      |   28 | 35000 |
| 16 | praveen | jntu      |   33 |   100 |
| 13 | revathi | jntu      |   26 | 20000 |
| 10 | venkat  | kphb      |   35 | 30000 |
+----+---------+-----------+------+-------+
9 rows in set (0.000 sec)

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

MariaDB [vlrinst]>

LOWER,LPAD,LTRIM,MID,POSITION,REPEAT functions sql videos in telugu 30

 https://youtu.be/JAIlcnYSWOA

------------------------------------------------
Sql Group 

https://t.me/joinchat/fRkYxinYGDY3MDRl
http://bit.ly/vlrsql

REPLACE Replaces all occurrences of a substring within a string, with a new substring

SELECT REPLACE("Vlr Training", "Training", "Technologies");

--------------------
REVERSE Reverses a string and returns the result

SELECT REVERSE("Vlr Training");
------------------------


RIGHT Extracts a number of characters from a string (starting from right)
SELECT RIGHT("Vlr Training", 4) AS ExtractString;
-------------------


RPAD Right-pads a string with another string, to a certain length
SELECT RPAD("Vlr Training", 20, "ABC");
------------------


RTRIM Removes trailing spaces from a string


SELECT RTRIM("Vlr Training    ") AS RightTrimmedString;

----------------------
SPACE Returns a string of the specified number of space characters
SELECT SPACE(10);
-------------------------


STRCMP Compares two strings

SELECT STRCMP("VLR Tutorial", "vlr Tutorial");
------------------------


SUBSTR Extracts a substring from a string (starting at any position)
SELECT SUBSTR("Vlr Tutorial", 5, 3) AS ExtractString;
----------------------

SUBSTRING Extracts a substring from a string (starting at any position)
SELECT SUBSTRING("SQL Tutorial", 5, 3) AS ExtractString;
---------------------


SUBSTRING_INDEX Returns a substring of a string before a specified number of delimiter occurs

SELECT SUBSTRING_INDEX("www.vlrtrain.com", ".", 1);
----

TRIM Removes leading and trailing spaces from a string

SELECT TRIM("    vlr Tutorial    ") AS TrimmedString;
---------------
UCASE Converts a string to upper-case
SELECT UCASE("SQL Training videos in telugu!");
---------------
UPPER Converts a string to upper-case
SELECT UPPER("SQL Training videos in telugu!");


-----------
MariaDB [vlrinst]> select name,replace(name,"r","T") from emp;
+---------+-----------------------+
| name    | replace(name,"r","T") |
+---------+-----------------------+
| venkat  | venkat                |
| praveen | pTaveen               |
| mounika | mounika               |
| revathi | Tevathi               |
| anji    | anji                  |
| harika  | haTika                |
| praveen | pTaveen               |
| pandu   | pandu                 |
| pandu   | pandu                 |
+---------+-----------------------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select name,reverse(name) from emp;
+---------+---------------+
| name    | reverse(name) |
+---------+---------------+
| venkat  | taknev        |
| praveen | neevarp       |
| mounika | akinuom       |
| revathi | ihtaver       |
| anji    | ijna          |
| harika  | akirah        |
| praveen | neevarp       |
| pandu   | udnap         |
| pandu   | udnap         |
+---------+---------------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select name,right(5) from emp;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual th
MariaDB [vlrinst]> select name,right(name,5) from emp;
+---------+---------------+
| name    | right(name,5) |
+---------+---------------+
| venkat  | enkat         |
| praveen | aveen         |
| mounika | unika         |
| revathi | vathi         |
| anji    | anji          |
| harika  | arika         |
| praveen | aveen         |
| pandu   | pandu         |
| pandu   | pandu         |
+---------+---------------+
9 rows in set (0.004 sec)

MariaDB [vlrinst]> select rpad("vlr training",8,"v");
+----------------------------+
| rpad("vlr training",8,"v") |
+----------------------------+
| vlr trai                   |
+----------------------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]> select name,sapce(20),age from emp;
ERROR 1305 (42000): FUNCTION vlrinst.sapce does not exist
MariaDB [vlrinst]> select name,space(20),age from emp;
+---------+----------------------+------+
| name    | space(20)            | age  |
+---------+----------------------+------+
| venkat  |                      |   35 |
| praveen |                      |   28 |
| mounika |                      |   22 |
| revathi |                      |   26 |
| anji    |                      |   28 |
| harika  |                      |   26 |
| praveen |                      |   33 |
| pandu   |                      |   35 |
| pandu   |                      |   23 |
+---------+----------------------+------+
9 rows in set (0.030 sec)

MariaDB [vlrinst]> select name,substring(name,3,5) from emp;
+---------+---------------------+
| name    | substring(name,3,5) |
+---------+---------------------+
| venkat  | nkat                |
| praveen | aveen               |
| mounika | unika               |
| revathi | vathi               |
| anji    | ji                  |
| harika  | rika                |
| praveen | aveen               |
| pandu   | ndu                 |
| pandu   | ndu                 |
+---------+---------------------+
9 rows in set (0.002 sec)

MariaDB [vlrinst]> select name,substring(name,3,2) from emp;
+---------+---------------------+
| name    | substring(name,3,2) |
+---------+---------------------+
| venkat  | nk                  |
| praveen | av                  |
| mounika | un                  |
| revathi | va                  |
| anji    | ji                  |
| harika  | ri                  |
| praveen | av                  |
| pandu   | nd                  |
| pandu   | nd                  |
+---------+---------------------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select SUBSTRING_INDEX("ram.cm.in",".",1);
+------------------------------------+
| SUBSTRING_INDEX("ram.cm.in",".",1) |
+------------------------------------+
| ram                                |
+------------------------------------+
1 row in set (0.000 sec)

MariaDB [vlrinst]> select SUBSTRING_INDEX("ram.cm.in",".",2);
+------------------------------------+
| SUBSTRING_INDEX("ram.cm.in",".",2) |
+------------------------------------+
| ram.cm                             |
+------------------------------------+
1 row in set (0.000 sec)

MariaDB [vlrinst]> select SUBSTRING_INDEX("ram.cm.in","m",2);
+------------------------------------+
| SUBSTRING_INDEX("ram.cm.in","m",2) |
+------------------------------------+
| ram.c                              |
+------------------------------------+
1 row in set (0.000 sec)

MariaDB [vlrinst]> select ucase(name), name from emp;
+-------------+---------+
| ucase(name) | name    |
+-------------+---------+
| VENKAT      | venkat  |
| PRAVEEN     | praveen |
| MOUNIKA     | mounika |
| REVATHI     | revathi |
| ANJI        | anji    |
| HARIKA      | harika  |
| PRAVEEN     | praveen |
| PANDU       | pandu   |
| PANDU       | pandu   |
+-------------+---------+
9 rows in set (0.001 sec)

MariaDB [vlrinst]> select upper(name), name from emp;
+-------------+---------+
| upper(name) | name    |
+-------------+---------+
| VENKAT      | venkat  |
| PRAVEEN     | praveen |
| MOUNIKA     | mounika |
| REVATHI     | revathi |
| ANJI        | anji    |
| HARIKA      | harika  |
| PRAVEEN     | praveen |
| PANDU       | pandu   |
| PANDU       | pandu   |
+-------------+---------+
9 rows in set (0.000 sec)

MariaDB [vlrinst]> select strcmp("Vlr","Vlr");
+---------------------+
| strcmp("Vlr","Vlr") |
+---------------------+
|                   0 |
+---------------------+
1 row in set (0.027 sec)

MariaDB [vlrinst]> select strcmp("Vlr","vlr");
+---------------------+
| strcmp("Vlr","vlr") |
+---------------------+
|                   0 |
+---------------------+
1 row in set (0.000 sec)

MariaDB [vlrinst]> select strcmp("Vlr","vlr1");
+----------------------+
| strcmp("Vlr","vlr1") |
+----------------------+
|                   -1 |
+----------------------+
1 row in set (0.001 sec)

MariaDB [vlrinst]>


*ReactJS Online Live Demo By Praveen Gubbala*
*Date:* 7PM(IST) 5th April 2021 (Monday)
*Join Link*
Interested to Join Plz share *Your Gmail to*
wa.me/919059868766
(Real Time Projects, PalceMent assistnce for Freshers and 2 to 4 years exp Students)