SQL Where: Uses and Examples

One of the most common programming languages ​​for working with databases is SQL. The language constructs allow not only to create a database, but also to carry out various manipulations with it to modify data or select it.

sql where




To select data from the database, use the Select [data set] from [table name] construct. As experience shows, in 80% of cases of using queries for data sampling, various conditions must be applied - parameters. To do this, the language, as an addition to the query, its complication, introduced the SQL-Where condition.

Ways to apply the Where clause

, , , . . , , , , . .

SQL-Where .

Where

, SQL-Where . :





  1. , Select * from.

  2. Join, .

  3. Where .

where sql examples




.

, , SQL-Where .

, , .

, , , .

Where

Where SQL. , — Tovar TovarAmount. , , , . , , .

, , , :

Select * from Tovar

Where T_Date >= ‘12/01/2016’ and T_Date<= ‘’12/07/1016 and T_PriceOut >0

, , , : T_PriceOut >0.

, , :

Select * from Tovar

Where T_Tovar in (select TA_Tovar where TA_ Amount> 0)

There can be many nested conditions in Where, but it is worth mentioning that the more conditions are imposed, the longer the query will work. This is what caused the use of temporary tables. It is much faster to generate several of these, and then compare the data in them, than to build a condition with several levels of data verification.




All Articles