OneCompiler

mysql till group by

234

CREATE TABLE student (
rollno INTEGER PRIMARY KEY,
name char(50),
subject char(30)
);

INSERT INTO student (rollno, name, subject)
VALUES (12, 'khushi', 'maths'),
(13, 'ruchi', 'science'),
(14, 'harsh', 'arts');
select * from student;
select * from student where rollno=12;
DESCRIBE student;
select DISTINCT rollno from student;
select rollno as id from student;
select * from student;
update student set name='sristi' where rollno=14;
select * from student;

CREATE TABLE csestudent (
rollno INTEGER PRIMARY KEY,
name char(50),
subject char(30)
);
INSERT INTO csestudent (rollno, name, subject)
VALUES (15, 'rishi', 'maths'),
(16, 'prachi', 'science'),
(17, 'sorav', 'arts');
select * from csestudent;

select rollno, name, subject from student
union all
select rollno, name, subject from csestudent;

select * from csestudent where rollno like '1%';
select * from csestudent where rollno IN (15, 16, 17);
select * from csestudent where rollno between 15 and 17;
select * from csestudent order by rollno desc;
select * from csestudent where rollno between 15 and 17 and subject='maths';
select * from csestudent where rollno ='15' or name="rishi";