1-bob. Ma`lumotlar bazasining asosiy tushunchalari


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


Download 281.59 Kb.
bet39/80
Sana20.11.2023
Hajmi281.59 Kb.
#1790121
1   ...   35   36   37   38   39   40   41   42   ...   80
Bog'liq
1-bob. Ma`lumotlar bazasining asosiy tushunchalari-fayllar.org

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


WHERE kurs=4 AND stipend 20;




  1. LPAD(,uzunlikunlik,[ satr>);


Berilgan uzunlikunlikdagi qism satrni chapdan, o’ngga joylashtiriladi. Agar qism satr ko’rsatilmagan bo’lsa, satr sukut bilan, probellar bilan to’ldiriladi. Agar uzunlik o’nlik satr unlikdan kerak bo’lsa berilgan satr ko’rsatilgan uzunlikunlikgacha qirqiladi.
Misol:


Download 281.59 Kb.

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