| Customer ID | Name | Surname | Date of Birth | City | Gender | Score |
| 1 | Ahmet | Cansever | 1956-02-19 00:00:00.000 | Istanbul | M | 64 |
| 2 | Mehmet | Aydın | 1976-02-19 00:00:00.000 | Samsun | M | 55 |
| 3 | Aliye | Seven | 1966-06-10 00:00:00.000 | Konya | F | 45 |
| 4 | Burak | Sayın | 1996-02-19 00:00:00.000 | Istanbul | M | 23 |
| 5 | Beyza | Kılıç | 1955-12-30 00:00:00.000 | Manisa | F | 85 |
To list the name and surname columns in the customer table;
SELECT name, surname FROM customer;
To list all records in the customer table;
SELECT * FROM customer;
A column in a table may contain duplicate values. With DISTINCT, we can list only unique values.
SELECT DISTINCT city FROM customer;
With the WHERE keyword, we can list only the records that match the specified condition.
SELECT * FROM customer WHERE city='Istanbul';
SELECT * FROM customer WHERE gender='F';
| Operator | Description |
|---|---|
| = | Equal |
| <> | Not equal |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal |
| <= | Less than or equal |
| BETWEEN | Between |
| LIKE | Pattern matching |
| IN | Specify multiple values |
SELECT * FROM customer
WHERE city='Istanbul'
AND gender='M';
SELECT * FROM customer
WHERE city='Istanbul'
OR city='Samsun';
SELECT * FROM customer
WHERE gender='F'
AND (city='Konya' OR city='Manisa');
SELECT * FROM customer ORDER BY name;
SELECT * FROM customer ORDER BY name DESC;
INSERT INTO customer(name, surname, birthDate, city, gender, score)
VALUES ('Ali','Şahin','2000-10-12','Burdur','M',68);
UPDATE customers
SET score=90
WHERE customerId=3;
DELETE FROM customers
WHERE customerId=4;
DELETE FROM customers;
SELECT TOP 5 * FROM customers;
SELECT * FROM customers WHERE city LIKE 'S%';
SELECT * FROM customers WHERE city LIKE '%s';
SELECT * FROM customers WHERE city LIKE '%tan%';
SELECT * FROM customers
WHERE city IN ('Istanbul','Konya');
SELECT * FROM customers
WHERE score NOT BETWEEN 70 AND 90;
SELECT name AS NAME, surname AS SURNAME, birthDate AS [DATE OF BIRTH]
FROM customers;
GROUP BY groups the selected dataset according to the specified columns. The HAVING clause is used after GROUP BY to filter grouped results.