Select statement (SQL)

SQL ( ) , - SQL. , , Select (SQL) - , .

select sql




, . SQL, Select () :

Select

, . .

One, two, three…

From

, . .

«» , , Select from .

:

select sql statement




Where , .





Group by, , Having.

Order by .

Select, , Cats :

Id

Breed

Name

Birthday

Color

1

01.04.2017

Grey

2

16.03.2017

White

3

30.03.2017

Black

4

23.02.2017

Grey

5

08.01.2017

Black

, , , . , Select (SQL), .

, .

Select . , :

Select color, breed, name

From Cats

, , . , .

. Select (*) . :

Select *

From Cats

- Cats, , .

, SQL Select . , , , .









Cats. , . (+), – (||) (&), Concat. , .

Select breed || ‘, ’ || color

From cats

:

Breed, Color

, Grey

, White

, Black

, Grey

, Black

sql select language




Distinct – Select (SQL), .

, , . :

Select breed

From Cats

:

Breed

, . Distinct , :

Select distinct breed

From Cats

. , Select (SQL) .

Where. – , "" "". Select , True, "".

. , .

Select *

From cats

Where color = ‘Black’

:

3

30.03.2017

Black

5

08.01.2017

Black

, And, Or, Not.

Group by

Group by, Select (SQL), ( ), .

:

  • Count – , .
  • Sum – .
  • Min – .
  • Max – , .
  • Avg – .

. , , . :

Select breed, count(*)

From cats

Group by breed

:

Breed

Count

2

1

1

1

, , . , , , , – .

, - , , , . Having. , Where, . . :

Select breed, count(*)

From cats

Group by breed

Having count(*) <=10

« 10», , . Having. Having count(*) =1, , .

Order by – Select (SQL), .

select function sql




, Order by – Select. Select, From, Where, Group by, Having.

:

1) , (ASC), (DESC).

2) Order by Select.

3) , , Select.

sql select to string




We hope that with the help of our article you have gained basic knowledge about using SQL queries and now you can easily select the necessary information from your DBMS.




All Articles