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 Persons( PersonId int , LastName varchar(20), FirstName varchar(20), Address varchar(20), City varchar(20) ); desc Persons; INSERT INTO Persons Values(111,'lakshmi','devi','hyderabad','kurnol'), (222,'ram','chou','Bangalore','kurnool'), (333,'risi','chou','Bangalore','Ananthapur'), (444,'rupa','chou','hyderabad','kurnool'); Select * from Persons; -- list the no.of persons in each city-- select City,count(PersonID) AS noofpersons from Persons group by city; UPDATE Persons SET City='kurnool' where PersonId=111; select City,count(PersonID) AS noofpersons from Persons group by city; ALTER TABLE Persons add column age int ; update Persons set age=25 where PersonId=111; update Persons set age=26 where PersonId=222; update Persons set age=25 where PersonId=333; update Persons set age=28 where PersonId=444; update Persons set age=29 where PersonId=555; select * from Persons; select City,COUNT(PersonID) as noOfPersons FROM Persons group by City having MAX(age)>25; select * UPPER(LastName) from Person;

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

Copy Clear