SELECT * FROM table_name WHERE column_name (operator) value
(operator) :- =, >, <,! and more operators.
A Friends table contains firstName, secondName, address, phone_no and firstName values are :- saurabh, sandy, gaurav, somu, saurabh and address column values are :- kanpur, allahabad, delhi, kanpur, varanasi.
SELECT * FROM Friends WHERE firstName = 'Saurabh' AND address = 'kanpur'
This will select only first row because only first row satisfies WHERE condition
SELECT * FROM Friends WHERE firstName = 'Saurabh' OR address = 'kanpur'
This will select first row, fourth row and fifth row due to oR condition in where clause
Operators :-
< :- lessthan
> :- greaterthan
<= :- less than or equal to
>= :- greater than or equal to
<> :- not equal to
BETWEEN :- between an inclusive range
LIKE :- for search pattern
IN :- SEARCH for exact values like if i know values are 1987, 1989
Use of IN clause :-
EXAMPLE :- SELECT * FROM Friends WHERE year IN (1987, 1989)
0 comments:
Post a Comment