2.2 SQLda amaliy jadval yaratish.
CREATE DATABASE klinika;
6-rasm KLINIKA mb yaratish
CREATE TABLE bemorlar (
ism VARCHAR(10) NOT NULL ,
familiya VARCHAR(10) NOT NULL,
tugilgan_sana DATE NOT NULL,
kassalik_tarixi TEXT NOT NULL,
kelgan_vaqti DATE NOT NULL,
tashxisi TEXT NOT NULL);
7-rasm jadval yaratish.
SELECT * FROM Customers
WHERE Country='Germany' AND (City='Berlin' OR City='München');
8-rasm and codini ishlatgandagi natija
3.1 Malumotlarni where ,order by,group by standart sintaksisidan foydalanib saralsh.
WHERE sintaksisi yozuvlarni filtrlash uchun ishlatiladi. U faqat belgilangan shartni bajaradigan yozuvlarni chiqarish uchun ishlatiladi..
SELECT * FROM Customers
WHERE Country='Mexico';
9-rasm WHERE sintaksisi natijasi.
ORDER BY kalit so'zi natijalar to'plamini o'sish yoki kamayish tartibida tartiblash uchun ishlatiladi. ORDER BY kalit so'zi sukut bo'yicha yozuvlarni o'sish tartibida tartiblaydi. Yozuvlarni kamayish tartibida saralash uchun DESC kalit so'zidan foydalaning.
SELECT * FROM Customers,
ORDER BY Country;
10-rasm order by sintaksisi natijasi
GROUP BY sintaksisi bir xil qiymatlarga ega boʻlgan satrlarni “har bir mamlakatdagi mijozlar sonini toping” kabi umumiy qatorlarga guruhlaydi.
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country;
11-rasm group by sintaksisi natijasi
3.2 MBda having , inner join union sintaksislarida misollar korish.
SELECT COUNT(CustomerID), Country
FROM Customers
GROUP BY Country
HAVING COUNT(CustomerID) > 5;
12-rasm having sintasksisi nstijasi
SELECT City FROM Customers
UNION
SELECT City FROM Suppliers
ORDER BY City;
13-rasm union sintaksisi natijasi
SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
14-rasm-rasm inner join sintaksisi natijasi
Do'stlaringiz bilan baham: |