My SQL
My SQL
--
DROP DATABASE college ;
-- The USE is used to access the file into the database to perform any operations
on them
USE college ;
-- To Create a table we used CREATE TABLE keyword and write the table name --
-- Also the under the () we are write the all content like student name , student
id , student age , etc... --
-- Also after write every row we used the , to end this row --
CREATE TABLE STUDENT (
STUDENT_ID INT PRIMARY KEY,
NAME VARCHAR(20),
AGE INT NOT NULL,
DOB DATE,
CONTACT_NUMBER VARCHAR(10),
ADDRESS VARCHAR(300),
BRANCH VARCHAR(30)
);
-- To insert the values in table we used INSERT INTO file_name VALUES (Enter
values) --
-- Also to write the string init we used single quotes or double quotes but there
are many cases people used single quotes so we prefer it --
-- INSERT INTO student VALUES (1, 'JAYESH', 22 , '1992-11-20' , '9876543210' ,
'Maple Avenue Skyline Apartments Flat Ten Pune Maharashtra India' , 'Computer
Science');
-- INSERT INTO student VALUES (2, 'MAYUR', 32 , '2002-05-15' , '9123456789' , 'Elm
Street Green Meadows Society Bengaluru Karnataka India' , 'Mechanical
Engineering');
-- INSERT INTO student VALUES (3, 'OM', 24 , '1998-09-10' , '9988776655' , 'River
Road Sunshine Complex Apartment Fifteen B Jaipur Rajasthan India' , 'Civil
Engineering');
-- INSERT INTO student VALUES (4, 'CHETAN', 42 , '1982-04-18' , '9123678456' , 'Oak
Lane Royal Residency Room Three Zero Two Mumbai Maharashtra India' , 'Electrical
Engineering');
-- INSERT INTO student VALUES (5, 'HITESH', 12 , '2012-03-25' , '9871234567' ,
'Pine Street Silver Sands Villas New Delhi Delhi India' , 'Electronics and
Communication');
-- INSERT INTO student VALUES (6, 'YESH', 43 , '1981-07-30' , '9098765432' ,
'Willow Drive Ocean Breeze Apartments Floor Five Hyderabad Telangana India' ,
'Information Technology');
-- INSERT INTO student VALUES (7, 'RAJ', 22 , '2002-08-12' , '9812345678' , 'Cedar
Avenue Palm Grove Tower Suite One Twenty Ahmedabad Gujarat India' , 'Chemical
Engineering');
-- At a one time we used the INSERT INTO and insert the multiple values in the
table like STUDENT_ID , NAME , AGE , DOB , CONTACT_NUMBER , ADDRESS , BRANCH
INSERT INTO student
(STUDENT_ID , NAME , AGE , DOB , CONTACT_NUMBER , ADDRESS , BRANCH)
VALUES
(1, 'JAYESH', 22 , '1992-11-20' , '9876543210' , 'Maple Avenue Skyline Apartments
Flat Ten Pune Maharashtra India' , 'Computer Science'),
(2, 'MAYUR', 32 , '2002-05-15' , '9123456789' , 'Elm Street Green Meadows Society
Bengaluru Karnataka India' , 'Mechanical Engineering'),
(3, 'OM', 24 , '1998-09-10' , '9988776655' , 'River Road Sunshine Complex Apartment
Fifteen B Jaipur Rajasthan India' , 'Civil Engineering'),
(4, 'CHETAN', 22 , '1982-04-18' , '9123678456' , 'Oak Lane Royal Residency Room
Three Zero Two Mumbai Maharashtra India' , 'Electrical Engineering'),
(5, 'HITESH', 12 , '2012-03-25' , '9871234567' , 'Pine Street Silver Sands Villas
New Delhi Delhi India' , 'Electronics and Communication'),
(6, 'YESH', 43 , '1981-07-30' , '9098765432' , 'Willow Drive Ocean Breeze
Apartments Floor Five Hyderabad Telangana India' , 'Information Technology'),
(6, 'YESH', 43 , '1981-07-30' , '9098765432' , 'Willow Drive Ocean Breeze
Apartments Floor Five Hyderabad Telangana India' , 'Computer Science'),
(7, 'RAJ', 22 , '2002-08-12' , '9812345678' , 'Cedar Avenue Palm Grove Tower Suite
One Twenty Ahmedabad Gujarat India' , 'Chemical Engineering');
-- By using the where we are able to find the data from the table by using the
speciffic condition --
SELECT * FROM STUDENT WHERE AGE = 22 ;
-- The SELECT * FROM write_file_name is used to get all information or data in the
form of table --
SELECT * FROM student ;
-- Also when we wont to get the same row then we used the GROUP
SELECT BRANCH , COUNT(NAME)
FROM STUDENT
GROUP BY BRANCH ;
USE college ;
-- It's used to display the all columns which are included into the table --
SELECT * FROM employee ;
SELECT * FROM employee WHERE GENDER = 'Male' AND SALARY > 50000 ;
-- Also we are able to setup the limit of an table output by using the LIMIT
SELECT * FROM employee WHERE GENDER = 'Male' AND SALARY > 50000 LIMIT 1 ;
-- We are also used the Aggregate Function like MAX , MIN , COUNT , SUM , AVG ,
etc...