Log in / Sign Up Create afreeW3Schools Account to Improve Your Learning Experience My Learning Track your learning progress at W3Schools and collect rewards Upgrade Become a PLUS user and unlock powerful features (ad-free, hosting, support,..) ...
ExampleGet your own SQL Server Return all customers from 'Germany', 'France', or 'UK' SELECT*FROMCustomers WHERECountryIN('Germany','France','UK'); Try it Yourself » Syntax SELECTcolumn_name(s) FROMtable_name WHEREcolumn_nameIN(value1,value2, ...); ...
The EXISTS operator is used to test for the existence of any record in a subquery.The EXISTS operator returns TRUE if the subquery returns one or more records.EXISTS SyntaxSELECT column_name(s) FROM table_name WHERE EXISTS(SELECT column_name FROM table_name WHERE condition); ...
The SQL UNION Operator TheUNIONoperator is used to combine the result-set of two or moreSELECTstatements. EverySELECTstatement withinUNIONmust have the same number of columns The columns must also have similar data types The columns in everySELECTstatement must also be in the same order...
TheEXISTSoperator is used to test for the existence of any record in a subquery. TheEXISTSoperator returns TRUE if the subquery returns one or more records. EXISTS Syntax SELECTcolumn_name(s) FROMtable_name WHEREEXISTS (SELECTcolumn_nameFROMtable_nameWHEREcondition); ...
You will learn more aboutwildcards in the next chapter. ExampleGet your own SQL Server Select all customers that starts with the letter "a": SELECT*FROMCustomers WHERECustomerNameLIKE'a%'; Try it Yourself » Syntax SELECTcolumn1, column2, ... ...
The SQL AND OperatorThe WHERE clause can contain one or many AND operators.The AND operator is used to filter records based on more than one condition, like if you want to return all customers from Spain that starts with the letter 'G':...
Track your progress - it's free! Log in Sign Up COLOR PICKER PLUS SPACES GET CERTIFIED FOR TEACHERS FOR BUSINESS CONTACT US Top Tutorials HTML Tutorial CSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ ...
The following SQL statement selects all customers with a CustomerName that have "or" in any position: Example SELECT*FROMCustomers WHERECustomerNameLIKE'%or%'; Try it Yourself » The following SQL statement selects all customers with a CustomerName that have "r" in the second position: ...
WHERE Price BETWEEN 10 AND 20AND CategoryID NOT IN (1,2,3); Try it Yourself » BETWEEN Text Values ExampleThe following SQL statement selects all products with a ProductName between "Carnarvon Tigers" and "Mozzarella di Giovanni":