1-bob. Ma`lumotlar bazasining asosiy tushunchalari


SELECT surname, name, stipend kurs, (stipend*kurs)/2; FROM Student


Download 1.69 Mb.
bet39/80
Sana17.06.2023
Hajmi1.69 Mb.
#1542331
1   ...   35   36   37   38   39   40   41   42   ...   80
Bog'liq
ec613b75a51decaf6d60405d564c5683 MySQL po max

SELECT surname, name, stipend kurs, (stipend*kurs)/2; FROM Student


WHERE kurs = 4 AND stipend >0


Joylashtirilgan so`rovlar


Misol. Joylashtirilgan so`rov:

SELECT name FROM users WHERE id_user IN (SELECT id_author FROM topics


WHERE topic_name='велосипедлар');

Misol. Xuddi shu so`rov:


SELECT name FROM users


WHERE id_user = (SELECT id_author FROM topics

WHERE topic_name='велосипедлар');


Moslashtirilgan so`rovda tashqi so`rov xar bir satri uchun ostki so`rov bajariladi


Misol:
SELECT *
FROM Customers outer
WHERE 10/03/1990 IN ( SELECT odate
FROM Orders inner
WHERE outer.cnum = inner.cnum );
Shu misol:
SELECT *
FROM Customers first, Orders second WHERE first.cnum = second.cnum AND second.odate = 10/03/1990; Misol.Tashqi so’rovdan foydalanish.
SELECT *
FROM Orders outer
WHERE amt > ( SELECT AVG amt
FROM Orders inter
WHERE inner.cnum = outer.cnum );


SQL da almashtirish funksiyalari bilan ishlash.

  1. LOWER ()- berilgan satrni kichik harflarga almashtirib beradi.

  2. UPPER () – kichik harflarni kata harflarga almashtirib beradi.

  3. INIT CAP ()- satrdagi har bir so’z unlikni 1-harfini bosh harf qilib beradi.

Maslan, ularga quyidagi misolni ko’ramiz. SELECT LOWER (surname), UPPER (name) FROM Student

Download 1.69 Mb.

Do'stlaringiz bilan baham:
1   ...   35   36   37   38   39   40   41   42   ...   80




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling