SQL Notes | 1 – SELECT , WHERE, ORDER BY, INSERT

SELECT 

-Customer tablosundaki tüm verileri çekmek için aşağıdaki ifadeyi kullanırız.

Select * from customers;

-Customers tablosundan City sütunundaki verileri çekmek için aşağıdaki ifadeyi kullanırız:

Select city from customers;

-Customer tablosundaki tüm farklı Country verilerini çekmek için aşağıdaki ifadeyi kullanabiliriz:

Select distinct countyr from customers;

WHERE

-City sütunundaki veriler ‘ İstanbul’ lanları çekmek için şu ifadeyi kullanabiliriz:

Select * from customers where city = ' İstanbul';

-NOT anahtar kelimesini kullanarak City verisi ‘ İstanbul’ olmayanları şöyle seçebiliriz:

Select * from customers where not city = ' İstanbul';

-Customers tablosundaki customerid değeri 18 olanları şu şekilde çekebiliriz:

Select * from customers where customerid = 18;

-Customers tablosundaki City değeri ‘İstanbul’ olan ve postalcode değeri 32200 olan kayıtları şu şekilde çekebilirz:

Select * from customers where city = ' İstanbul' and  postalcode = 32200;

-Customers tablosundaki City sütunundaki veriler ‘ İstanbul’ veya ‘Balıkesir’ olanlanları çekmek için şu ifadeyi kullanabiliriz:

Select * from customers where city = ' İstanbul' or city = 'Balıkesir' ;

ORDER BY

-Customers tablosundaki City sütunundaki verileri alfabetik olarak sıralı çekmek için şu ifadeyi kullanabiliriz:

Select * from customers where order by city;

-Customers tablosundaki Country ve City sütunundaki verileri, önce Country sonra da City için alfabetik olarak sıralı çekmek için şu ifadeyi kullanabiliriz:

Select * from customers where order by country, city;

INSERT

-Customer tablosuna yeni bir kayıt eklemeyi şu ifadeyle yapabiliriz:

Insert into Customers
(CustomerName,
Address,
City,
PostalCode,
Country)
values
('Ahmet Gürsoy',
'Beyoğlu',
'İstanbul',
'32000',
'Türkiye');