codingtcher.com
Theme Night
Home
Login

Sql Where

Home » Sql » Sql Where

WHERE keyword SQL

-- The WHERE keyword allows you to filter based on both text and numeric values in a table. 

-- There are a few different comparison operators you can use:
-- = equal
-- <> not equal
-- < less than
-- > greater than
-- <= less than or equal to
-- >= greater than or equal to

SELECT example_column
FROM example_table
WHERE example_column = 'example_value';

sql where clause

/*using of where clause*/
Select * from customer
where customer_id = 1

sql select where in

SELECT * FROM table_name WHERE country IN ('SPAIN', 'MEXICO');

sql where multiple values

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...); 

sql select

SELECT * FROM TABLE_NAME;

sql select where

SELECT * FROM table_name;
-- Sorting col1 ASCending then col2 DESCending
SELECT col1, col2 FROM table_name ORDER BY col1 ASC, col2 DESC;
-- Filter on col1
SELECT col1, col2 FROM table_name WHERE col1 = 'a value';
-- Containing 'searched'
SELECT col1, col2 FROM table_name WHERE col1 LIKE '%searched%';
-- All different values
SELECT DISTINCT col1 FROM table_name;
-- Simple sum
SELECT col1, sum(col2) FROM table_name GROUP BY col1;

Sql Related Post