MYSQL BASIC TO ADVANCE Info For All Types of Interviews
MYSQL BASIC TO ADVANCE Info For All Types of Interviews
CREATE
Database Related Queries DROP
USE
SHOW
CREATE
DESC
INSERT
SELECT & VIEW
DELETE
UPDATE
DROP
Table Related Queries DISTINCT
ALTER
ADD
DROP
MYSQL RENAME
CHANGE
MODIFY
NOT NULL
DEFAULT
PRIMARY KEY
Constraints FOREIGN KEY
AUTO_INCREMENT
CHECK
UNIQUE
SUM()
AVG()
MAX()
Aggregate functions MIN()
COUNT()
WITH WHERE
LIKE
IN
CLAUSE BETWEEN
ANY
EXISTS
AND/OR/NOT
OTHER
ORDER BY
LIMIT
INNER JOIN GROUP BY
HAVING
OUTER JOIN
JOINS LEFT OUTER JOIN
RIGHT OUTER JOIN
FULL OUTER JOIN
CONCAT()
MYSQL CONCAT_WS()
SUBSTR()
REPLACE()
REVERSE()
STRING FUNCTIONS UPPER()/LOWER()
CHAR_LENGTH()
LEFT()
RIGHT()
TRIM()
NOW()
CURDATE()
CURTIME()
DATE()
DATE AND TIME TIME()
FUNCTIONS YEAR()
MONTH()
DAY() /DAYOFMONTH()
HOUR()
MINUTE()
SECOND()
Database related Queries
1. CREATE
3.USE
5. DELETE
6.UPDATE
8. DISTINCT
3. RENAME
The CHANGE statement is used to rename a column and change its data
type simultaneously.
5. MODIFY
The NOT NULL constraint ensures that a column cannot have a NULL
value. It forces a column to always contain a value.
7.UNIQUE
2.AVG()
3.MAX()
5.COUNT()
Syntax :
SELECT * FROM table_name WHERE column_name IN (value1,
value2, ...);
3.BETWEEN
The BETWEEN operator selects values within a given range. The values
can be numbers, text, or dates
The ANY operator is used to compare a value with any value in a list or
subquery.
The EXISTS operator is used to test for the existence of any record in a
subquery. It returns TRUE if the subquery returns one or more records.
Syntax :
SELECT * FROM table_name WHERE EXISTS (subquery);
6.AND/OR/NOT
These are logical operators used to filter records based on more than
one condition:
AND: Returns records that satisfy all conditions.
OR: Returns records that satisfy any of the conditions.
NOT: Excludes records that meet the condition.
The ORDER BY clause is used to sort the result set of a query by one or
more columns in ascending or descending order.
The LIMIT clause is used to specify the number of records to return from
the result set.
The GROUP BY clause is used to group rows that have the same values into
summary rows, often used with aggregate functions like COUNT, SUM, AVG, etc.
The HAVING clause is used to filter groups after they are created by the
GROUP BY clause. It’s similar to the WHERE clause but works on
aggregated data.
2.OUTER JOIN
LEFT OUTER JOIN (or LEFT JOIN)
RIGHT OUTER JOIN (or RIGHT JOIN)
FULL OUTER JOIN
Returns all records from the left table, and the matched records from
the right table. If no match, NULLs are returned from the right table.
Returns all records from the right table, and the matched records from
the left table. If no match, NULLs are returned from the left table.
Returns all records when there is a match in either left or right table. If
there is no match, NULLs are returned from the non-matching table.
2.CONCAT_WS()
3.SUBSTR() / SUBSTRING()
5.REVERSE()
Syntax:SELECT REVERSE('SQL');
6.UPPER() / LOWER()
Syntax:SELECT UPPER('hello');
SELECT LOWER('HELLO');
7.CHAR_LENGTH()
8.LEFT()
9.RIGHT()
10.TRIM()
2.CURDATE()
Syntax:SELECT CURDATE();
3.CURTIME()
Syntax:SELECT CURTIME();
4.DATE()
Syntax:SELECT DATE();
5.TIME()
6.YEAR()
Syntax:SELECT YEAR();
7.MONTH()
Syntax:SELECT MONTH();
8.DAY() / DAYOFMONTH()
Syntax:SELECT DAY();
9.HOUR()
10.MINUTE()
Syntax:SELECT MINUTE();
11.SECOND()
Syntax:SELECT SECOND();