Notes
Notes - notes.io |
+----+-------+------+
| id | ad | stok |
+----+-------+------+
| 1 | Elma | 500 |
| 2 | Armut | 1000 |
+----+-------+------+
2 rows in set
mysql> select * from satis;
Empty set
mysql> insert into satis values (0, now(), 1, 150);
Query OK, 1 row affected
mysql> select * from satis;
+----+---------------------+-----------------+----------------+
| id | satis_tarihi | satilan_urun_id | satilan_miktar |
+----+---------------------+-----------------+----------------+
| 1 | 2016-10-14 09:31:46 | 1 | 150 |
+----+---------------------+-----------------+----------------+
1 row in set
mysql> select * from urunler;
+----+-------+------+
| id | ad | stok |
+----+-------+------+
| 1 | Elma | 350 |
| 2 | Armut | 1000 |
+----+-------+------+
2 rows in set
mysql> delete from satis where id = 1;
Query OK, 1 row affected
mysql> select * from urunler
-> ;
+----+-------+------+
| id | ad | stok |
+----+-------+------+
| 1 | Elma | 500 |
| 2 | Armut | 1000 |
+----+-------+------+
2 rows in set
mysql>
create table urunler
(
id int primary key auto_increment,
ad varchar(50),
stok int
);
insert into urunler values (0,'Elma',500);
insert into urunler values (0,'Armut',1000);
select * from urunler;
create table satis
(
id int primary key auto_increment,
satis_tarihi datetime,
satilan_urun_id int,
satilan_miktar INT
);
-- satis tablosuna kayit eklendikten sonra
-- calisacak trig_satis_yap triggerini tanimla
create trigger trig_satis_yap
after insert on satis
for each row
BEGIN
update urunler set stok = stok - new.satilan_miktar
where id = new.satilan_urun_id;
end;
-- satis tablosunda kayit silindikten sonra
-- calisacak trig_satis_iptal triggerini tanimla
create trigger trig_satis_iptal after delete on satis
for each row
BEGIN
update urunler set stok = stok + old.satilan_miktar
where id = old.satilan_urun_id;
end;
-- trigger ile loglama
-- log tablosunu olustur
create table kisiler_logs (islem varchar(50), tarih datetime, aciklama varchar(255));
create trigger trig_kisi_ekle
after insert on kisiler
for each row
BEGIN
insert into kisiler_logs values ('INSERT', now(), concat(new.ad,' ',new.soyad,' isimli kayit eklendi') );
end;
|
Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 12 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team