, NOT, AND & BETWEEN Commands in SQL

NOT, AND & BETWEEN Commands in SQL

NOT, AND & BETWEEN Commands in SQL

[ad_1]


This write-up wuill deliver an clarification of how to use the subsequent commands in SQL

NOT

The NOT command is applied to exclude facts centered on some conditions. In the illustration, under we will use the NOT command to exclude basketball players who participate in the electricity ahead or taking pictures guard situation. The code is following adopted by the output.

Select *
FROM Seasons_Stats
In which Pos NOT IN ('PF','SG')
NOT, AND & BETWEEN Commands in SQL 13

Right here is a breakdown of the code.

  1. Line 1 tells SQL to pick all columns in the dataset
  2. Line 2 describe which desk to use
  3. Line 3 Use the The place command initial which serves as a filter. Next, the NOT command signifies to exclude what will come upcoming. The IN command signifies especially what will be excluded. The details in the parentheses is the types to get rid of from the column identified as “POS”
, NOT, AND & BETWEEN Commands in SQL

IF you seem at the initial 10 rows shown previously mentioned you will see there are no PF or SG in the POS column which is what we desired.

The illustration higher than excluded textual content info but we can also exclude numerical values as effectively. In the code below we swap the “Pos” column with the “Year” and we exclude the A long time of 1950 and 1051. The code and output are down below.

Select *
FROM Seasons_Stats
Exactly where "Year" NOT IN (1950,1951)
, NOT, AND & BETWEEN Commands in SQL
NOT, AND & BETWEEN Commands in SQL 14

If you glimpse at the “Year” colum you can see it does not commence till 1952. In addition. you can clearly see that there are PF and SG in the “Pos” column which utilized to be what we exlcuded in the former illustration.

AND Command

The AND command is employed whe n you have a number of conditions for which include or excluding information and facts. In the code underneath we proceed to exlcude plauers from 1950 and 1951 but then with the AND command we exclude gamers whose initial identify starts with an A. Beneath is the code and output.

Choose *
FROM Seasons_Stats
The place "Calendar year" NOT IN (1950,1951) AND NOT Participant LIKE 'A%'
Purchase BY Participant 
, NOT, AND & BETWEEN Commands in SQL
NOT, AND & BETWEEN Commands in SQL 15

What is new this time is the use of the LIKE command which is utilized when you are not specifically positive what you are seeking for. THis is way the “A” is in sinle quotations adopted by the p.c indicator. THis tells SQL to exclude anything at all that starts with an A.

Involving Command

The Involving command is when you are hunting to involve values that fit a specific selection. In the code beneath, we take out the NOT command and contain the Among and the AND command. THis implies that we want to incorporate rows that meet up with our critria somewhat than exlcude them.

Select *
FROM Seasons_Stats
Wherever Age Concerning 41 AND 43
Get BY Age
, NOT, AND & BETWEEN Commands in SQL
NOT, AND & BETWEEN Commands in SQL 16

In this code we want any participant who is among 41 and 43 a long time of age. Underneath is the exact output but published with the use of the NOT command

Choose *
FROM Seasons_Stats
Wherever Age NOT Among 18 AND 40
Buy BY Age
, NOT, AND & BETWEEN Commands in SQL
NOT, AND & BETWEEN Commands in SQL 17

Which is much better in all probability comes down to preference

Conclusion

The commands pointed out in this article are between some of the basic resources any individual who would like to use SQL desires to know. In the foreseeable future we will deal with other ideas connected to SQL

[ad_2]

Supply url

See also  Attitude Shayari In Hindi For WhatsApp & Instagram 2021