Mysql queries

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CREATE DATABASE collegeDB;

SHOW DATABASES;

USE collegeDB;

CREATE TABLE student (USN varchar(15) primary key, Sname char(20) not null, Address varchar(30) not null, Phone
varchar(10) not null, Gender char(1) not null);

create table department (DeptNo varchar(15) primary key, DeptName varchar(30) not null);

create table staff (SID varchar(15) primary key, Sname varchar(20) not null, Address varchar(30) not null, Phone
varchar(10) not null, DeptNo varchar(15), FOREIGN KEY (DeptNo) References Department(DeptNo) );

insert into student values('1DS19ISO25','Avani','Bangalore','9008958757','F');

insert into student values('1DS19ISO42','Gowthami','Udupi','9449665626','F');

insert into student values('1DS19ISO40','Kumar','Mysore','9449640611','M');

insert into student values('1DS19ISO39','Disha','Mangalore','8762076787','F');

insert into student values('1DS19ISO60','Suresh','Ranchi','9123455569','M');

insert into department values('001depCS', 'ComputerScience');

insert into department values('002depCA', 'ComputerApplications');

insert into department values('003depIT', 'InformationTechnology');

insert into staff values('01STCA001', 'Hari','Bangalore','9873673885','002depCA');

insert into staff values('01STIT002', 'Lokeshi','Chennai','7458357071','003depIT');

select * from student;

Select * from department;

Select * from staff;

Select Sname from staff where SID ='01stca001';

Select Sname,DeptName from staff,department where staff.DeptNo=department.Deptno;

Select * from Student where gender='M';

You might also like