SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
create TABLE t ( EmpID INT NOT NULL, NewVacationHours INT, ModifiedDate TIMESTAMP); INSERT INTO t values (1, 0, NULL); INSERT INTO t values (2, 0, NULL); INSERT INTO t values (3, 0, NULL); create TABLE Empl ( BusinessEntityID INT NOT NULL, VacationHours INT); INSERT INTO Empl values (1, 10); INSERT INTO Empl values (2, 20); INSERT INTO Empl values (3, 30); select NewVacationHours , e.VacationHours + 20, ModifiedDate FROM t, Empl AS e WHERE e.BusinessEntityID = EmpID; UPDATE t SET NewVacationHours = e.VacationHours + 20 FROM Empl AS e WHERE e.BusinessEntityID = EmpID; select * from t; select * FROM Empl AS pe INNER JOIN t AS pt ON pe.BusinessEntityID = pt.EmpID WHERE pe.BusinessEntityID > 2; DELETE pe FROM Empl AS pe INNER JOIN t AS pt ON pe.BusinessEntityID = pt.EmpID WHERE pe.BusinessEntityID > 2; select * from Empl; update pe set pe.BusinessEntityID = pe.BusinessEntityID + 100 FROM Empl AS pe INNER JOIN t AS pt ON pe.BusinessEntityID = pt.EmpID WHERE pe.BusinessEntityID <= 2; select * from Empl; update Empl set BusinessEntityID = BusinessEntityID + 100 FROM Empl AS pe INNER JOIN t AS pt ON pe.BusinessEntityID = pt.EmpID WHERE pe.BusinessEntityID <= 2; select * from Empl; drop table t; drop table empl;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear