SELECT AND SQL Server Syntax Example: SELECT AND logical operator T-SQL Example

SELECT AND SQL Server Syntax Example: SELECT AND logical operator T-SQL Example

Purpose: – Illustrates the for the .

Syntax: SELECT [ ALL | DISTINCT ]
[TOP ( expression ) [PERCENT] [ WITH TIES ] ]
select_list
[ INTO new_table ]
[ FROM { table_source } [ ,…n ] ]
[ WHERE search_condition AND search_condition ]
[ GROUP BY ]
[ HAVING search_condition ]
– AND indicates both search_conditions must be true for records to be included in search results

View Other SQL Server Syntax Examples

-- SELECT AND 
-- PURPOSE: AND is a logical connector between two conditions in where clause that
--          indicates both conditions must be true 
-- SYNTAX: SELECT [ ALL | DISTINCT ] 
--			[TOP ( expression ) [PERCENT] [ WITH TIES ] ] 
--			< select_list > 
--			[ INTO new_table ] 
--			[ FROM { <table_source> } [ ,...n ] ] 
--			[ WHERE <search_condition> AND </search_condition><search_condition> ] 
--			[ <group BY> ] 
--			[ HAVING < search_condition > ] 
 
 
CREATE TABLE people(
     ID          int,
     name        varchar (20),
     height      int )
 GO
 
 
 
 
 INSERT INTO people (ID, name, height) VALUES (1,  'Paul', 72)
 GO
 
 INSERT INTO people (ID, name, height) VALUES (2,  'John', 69)
 GO
 
 INSERT INTO people (ID, name, height) VALUES (3,  'Steve', 75)
 GO
 
 INSERT INTO people (ID, name, height) VALUES (4,  'Steve', 65)
 GO
 
 
-- AND indicates both conditions must be true
 SELECT * FROM people
 WHERE height > 66 and height < 72;
 GO
 
 
 drop table people;
 
 GO

Sample Output for SELECT ALL Example

Folder