Ustunlarni birlashtirish
mysql> create function birlashtirish(
-> ism text charset utf8,
-> fam text charset utf8,
-> ota text charset utf8)
-> returns text charset utf8
-> reads sql data
-> begin
-> return concat(
-> ism, ' ', fam, ' ', ota);
-> end//
Query OK, 0 rows affected (0.09 sec)
mysql> select birlashtirish(ismi, familyasi, otasining_ismi) from bemorlar_2;
-> //
+------------------------------------------------+
| birlashtirish(ismi, familyasi, otasining_ismi) |
+------------------------------------------------+
| Botir Ahrorov Ziyatovich |
| Dilobar Saidova Davron qizi |
| Qayyum Ahad Jobirovich |
| Davron Qodirov Otaxonovich |
| Farzona Mo`minova Ahmadjon qizi |
| Vladimir Belyakov Gennadevich |
| Andrey ╨Рndreev Ivanovich |
| Liliya Muxamadullina Nailevna |
| Elvira ╨Рbdullina Rashidovna |
| Viktoriya Gayfullina ╨Рleksandrovna |
| Bekzod Asadov Valiyevich |
| Temur Ahrorov Aliyevich |
+------------------------------------------------+
12 rows in set (0.00 sec)
Mavjud standart funksiyalar(10-lab)dan foydalanib yangi funksiya yaratish.
mysql> create function uzunligi(s varchar(30))
-> returns int
-> deterministic
-> begin
-> declare result int;
-> set result = length(s);
-> return (result);
-> end//
Query OK, 0 rows affected (0.11 sec)
mysql> select uzunligi('Abdurauf')//
+----------------------+
| uzunligi('Abdurauf') |
+----------------------+
| 8 |
+----------------------+
1 row in set (0.00 sec)
mysql>
TRIGGERS
After delete
mysql> create trigger tuzalgan_bemorlar
-> after delete
-> on bemorlar_2
-> for each row
-> set @del = @del + 1;
-> //
Query OK, 0 rows affected (0.25 sec)
Dostları ilə paylaş: |