https://github.com/sanam2405/sql
Learning Structured Query Language
https://github.com/sanam2405/sql
sql
Last synced: 5 months ago
JSON representation
Learning Structured Query Language
- Host: GitHub
- URL: https://github.com/sanam2405/sql
- Owner: sanam2405
- Created: 2023-07-02T01:53:32.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-04T07:48:51.000Z (almost 3 years ago)
- Last Synced: 2025-04-09T19:38:14.083Z (about 1 year ago)
- Topics: sql
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SQL
Learning Structured Query Language
## Methods
- Check if an expression returns NULL
```console
IFNULL(,)
```
- Limit the number of results printed on firing a given query
```console
LIMIT ,
```
- Find the difference between two dates
```console
DATEDIFF(,)
```
- Match a Regular Expression or REGEX
```console
LIKE
```
- Concatenate the results of a query into a single row
```console
GROUP_CONCAT()
```
- Find the unique or distinct values across all the rows of a column
```console
DISTINCT
```
- Group multiple similar rows of a particular column
```console
GROUP BY
```
- Order the output by ascending or descending order on firing a given query
```console
ORDER BY DESC
```
- Specify conditions to query rows from a table
```console
WHERE
```
- Specify conditions to query groups from a table, after GROUP BY has been applied
```console
HAVING
```
- Extract a substring. 1-based indexing is followed in MySQL
```console
SUBSTR(,,)
SUBSTR(,)
```
- Concatenate strings and varchars
```console
CONCAT(,)
```
- Change to upper case
```console
UPPER()
```
- Change to lower case
```console
LOWER()
```
- Check a value against multiple rows from a subquery
```console
IN()
```
- Switch-Case Statement
```console
CASE
WHEN THEN
WHEN THEN
ELSE
END
```
- If Statement
```console
IF(,,)
```
- Alter and Rename the Column name
```console
ALTER
RENAME COLUMN
```
- Update values in a Row, If the row is not present then nothing happens
```console
UPDATE
SET ,
WHERE
```
- Insert values in a Row
```console
INSERT INTO
(
,
)
VALUES
(
,
)
```
- Replace values in a Row, If the row is not present, then a new row is created. Replace = Insert+Update
```console
REPLACE INTO
(
,
)
VALUES
(
,
)
```
- Rename the Table
```console
ALTER TABLE
RENAME TO
```