Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE Department ( dept_id int primary key, dept_name varchar(10) not null ); CREATE TABLE Student ( student_id int primary key,student_name varchar(25),age int, marks int, dept_id int, foreign key(dept_id) references Department(dept_id)); insert into Department values (1,"Cs"),(2,"Mech"),(3,"Business"); INSERT INTO Student VALUES (101, "Alice",25,85,1),(102,"Bob",21,75,2),(103,"Charlie",22,95,1), (104,"Diana",20,65,3),(105,"Eva",23,70,2); select * from Department; select * from Student; select dept_name,count(*),avg(marks),max(marks) from Department join Student on Department.dept_id=Student.dept_id group by dept_name create table log(s_id int , oldm int , newm int , change_date timestamjp default current_timestamp); create or replace trigger after_up after update on Student for each row begin insert into log(s_id,oldm,newm,new) values(:old.s_id,old.:marks,:new.marks); END; / update Student set marks=88 where student_id=103; select * from log;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear