You are on page 1of 5

CREATE TABLE students

(
student_id int AUTO_INCREMENT NOT NULL,
student_fname varchar(30) NOT NULL,
student_mname varchar(30) ,
student_lname varchar(30) NOT NULL,
student_email varchar(30) NOT NULL,
student_phone varchar(15) NOT NULL,
student_alternate_phone varchar(15),
enrollment_date TIMESTAMP NOT NULL,
years_of_exp int NOT NULL,
student_company varchar(30) ,
batch_date varchar(30) NOT NULL,
source_of_joining varchar(30) NOT NULL,
location varchar(30) NOT NULL,
PRIMARY KEY(student_id),
UNIQUE KEY (student_email)
);

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('rohit','sharma','rohit@gmail.com','9191574733',6,'walmart','5-1-
2023','linkedin','banglore');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('virat','kohli','virat@gmail.com','9291574733',4,'netflix','5-1-
2023','linkedin','delhi');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('shubhman','gill','gill@gmail.com','9391574733',1,'paypal','19-2-
2023','youtube','pune');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('shreyas','iyer','shreyas@gmail.com','9491574733',2,'amazon','19-2-
2023','friend','mumbai');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('nitish','rana','nitish@gmail.com','9591574733',1,'microsoft','2-3-
2023','linkedin','gurugram'),
('rahul','dravid','rahul@gmail.com','9691574733',8,'tcs','5-1-
2023','google','banglore'),
('vvs','laxman','vvs@gmail.com','9791574733',7,'wipro','5-1-
2023','youtube','hyderabad'),
('ishan','kishan','ishan@gmail.com','9891574733',1,'infosys','19-2-
2023','linkedin','patana');
select student_id ,enrollment_date, student_fname,
student_lname,student_email,years_of_exp, student_company,batch_date,
source_of_joining, location from students;

INSERT INTO courses VALUES (1,'big-data',6,50000),(2,'web-devlopment',3,10000),


(3,'data-science',8,80000),(4,'devops',4,20000);

CREATE TABLE students


(
student_id int AUTO_INCREMENT NOT NULL,
student_fname varchar(30) NOT NULL,
student_mname varchar(30) ,
student_lname varchar(30) NOT NULL,
student_email varchar(30) NOT NULL,
student_phone varchar(15) NOT NULL,
student_alternate_phone varchar(15),
selected_course int NOT NULL DEFAULT 1,
enrollment_date TIMESTAMP NOT NULL,
years_of_exp int NOT NULL,
student_company varchar(30) ,
batch_date varchar(30) NOT NULL,
source_of_joining varchar(30) NOT NULL,
location varchar(30) NOT NULL,
PRIMARY KEY(student_id),
UNIQUE KEY (student_email)
);

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,batch_date,
source_of_joining,location) VALUES
('rohit','sharma','rohit@gmail.com','9191574733',3,6,'walmart','5-1-
2023','linkedin','banglore');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,batch_date,
source_of_joining,location) VALUES
('virat','kohli','virat@gmail.com','9291574733',1,4,'netflix','5-1-
2023','linkedin','delhi');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,batch_date,
source_of_joining,location) VALUES
('shubhman','gill','gill@gmail.com','9391574733',1,'paypal','19-2-
2023','youtube','pune');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,batch_date,
source_of_joining,location) VALUES
('shreyas','iyer','shreyas@gmail.com','9491574733',2,2,'amazon','19-2-
2023','friend','mumbai');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,batch_date,
source_of_joining,location) VALUES
('nitish','rana','nitish@gmail.com','9591574733',4,1,'microsoft','2-3-
2023','linkedin','gurugram'),
('rahul','dravid','rahul@gmail.com','9691574733',2,8,'tcs','5-1-
2023','google','banglore'),
('vvs','laxman','vvs@gmail.com','9791574733',1,7,'wipro','5-1-
2023','youtube','hyderabad'),
('ishan','kishan','ishan@gmail.com','9891574733',3,1,'infosys','19-2-
2023','linkedin','patana');

select student_id , student_fname,student_email,years_of_exp,


student_company,selected_course from students ;

CREATE TABLE students


(
student_id int AUTO_INCREMENT NOT NULL,
student_fname varchar(30) NOT NULL,
student_mname varchar(30) ,
student_lname varchar(30) NOT NULL,
student_email varchar(30) NOT NULL,
student_phone varchar(15) NOT NULL,
student_alternate_phone varchar(15),
selected_course int NOT NULL DEFAULT 1,
enrollment_date TIMESTAMP NOT NULL,
years_of_exp int NOT NULL,
student_company varchar(30) ,
batch_date varchar(30) NOT NULL,
source_of_joining varchar(30) NOT NULL,
location varchar(30) NOT NULL,
PRIMARY KEY(student_id),
UNIQUE KEY (student_email),
FOREIGN KEY (selected_course) REFERENCES courses(course_id)
);

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,
batch_date,source_of_joining,location) VALUES
('rohit','sharma','rohit@gmail.com','9191574733',3,6,'walmart','5-1-
2023','linkedin',
'banglore');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,
batch_date,source_of_joining,location) VALUES
('virat','kohli','virat@gmail.com','9291574733',1,4,'netflix','5-1-
2023','linkedin','delhi');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,years_of_exp,stude
nt_company,
batch_date,source_of_joining,location) VALUES
('shubhman','gill','gill@gmail.com','9391574733',1,'paypal','19-2-2023','youtube',
'pune');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,
batch_date,source_of_joining,location) VALUES
('shreyas','iyer','shreyas@gmail.com','9491574733',2,2,'amazon','19-2-
2023','friend',
'mumbai');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,batch_date,
source_of_joining,location) VALUES
('nitish','rana','nitish@gmail.com','9591574733',4,1,'microsoft','2-3-
2023','linkedin','gurugram'),
('rahul','dravid','rahul@gmail.com','9691574733',2,8,'tcs','5-1-
2023','google','banglore'),
('vvs','laxman','vvs@gmail.com','9791574733',1,7,'wipro','5-1-
2023','youtube','hyderabad'),
('ishan','kishan','ishan@gmail.com','9891574733',3,1,'infosys','19-2-
2023','linkedin','patana');

INSERT INTO
students(student_fname,student_lname,student_email,student_phone,selected_course,ye
ars_of_exp,student_company,
batch_date,source_of_joining,location) VALUES
('jasprit','bumrah','jasprit@gmail.com','9198574733',8,4,'paytm','5-1-
2023','linkedin',
'ahmedabad');

CREATE TABLE courses_new


(
course_id int NOT NULL,
course_name varchar(30) NOT NULL,
course_duration_months decimal(3,1) NOT NULL,
course_fees int NOT NULL,
changed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP( ) ON UPDATE CURRENT_TIMESTAMP(
),
PRIMARY KEY(course_id)
);

INSERT INTO courses_new(course_id,course_name,course_duration_months,course_fees)


VALUES (1,"big-data",6.5,50000);

INSERT INTO courses_new(course_id,course_name,course_duration_months,course_fees)


VALUES (2,"data-science",9.5,100000);

INSERT INTO courses_new(course_id,course_name,course_duration_months,course_fees)


VALUES (3,"machine-learning",12,150000);
INSERT INTO courses_new(course_id,course_name,course_duration_months,course_fees)
VALUES (4,"dev-ops",8.5,40000);

select student_fname,student_lname,course_name from students join courses on


selected_course=course_id;

select student_fname,student_lname,course_name from students join courses on


course_id=selected_course;

### new compiler

CREATE TABLE employee


(
firstname varchar(20),
lastname varchar(20),
age int,
salary int,
location varchar(20)
);

INSERT INTO employee VALUES ("sachin","sharma",28,10000,"banglore");

INSERT INTO employee VALUES ("shane","warne",30,20000,"banglore");

INSERT INTO employee VALUES ("rohit","sharma",32,30000,"hyderabad");

INSERT INTO employee VALUES ("shikhar","dhawan",32,25000,"hyderabad");

INSERT INTO employee VALUES ("rahul","dravid",31,20000,"banglore");

INSERT INTO employee VALUES ("saurabh","ganguly",32,15000,"pune");

INSERT INTO employee VALUES ("kapil","dev",34,10000,"pune");

You might also like