Posts

Showing posts from July, 2022

MySQL INDEX

Image
What is Index?  How to work Index in mysql: Syntax: Guidelines of Index : Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); INDEX Examples ...

MySQL VIEW

Image
 How to work View In MySql: INNER Join Syntax: Create View Syntax: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); VIEW Examples /* Creat...

MySQL DROP & TRUNCATE

Image
  How to Work Drop & Truncate in MySql: Syntax: DROP & TRUNCATE TRUNCATE TABLE courses ; DROP TABLE courses ;

MySQL ALTER

Image
 How to Modify tables in MySql: Features of MySql Alter command: Alter Syntax: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); ALTER Exam...

MySQL Time Functions

Image
How to work Time Function in MySql: Code: SELECT CURRENT_TIME(); SELECT CURTIME(); SELECT CURRENT_TIMESTAMP(); SELECT LOCALTIME(); SELECT LOCALTIMESTAMP(); SELECT TIME("2019-06-15 13:15:20") AS Time; SELECT HOUR("2019-06-15 13:15:20") AS Time; SELECT MINUTE("2019-06-15 13:15:20") AS Time; SELECT SECOND("2019-06-15 13:15:20") AS Time; SELECT MICROSECOND("2019-06-15 13:15:20") AS Time; SELECT TIMEDIFF("18:10:11","13:15:20") AS Time; SELECT TIMEDIFF("14:10:11","13:15:20") AS Time; SELECT ADDTIME("2019-06-15 05:30:20.000001","5:5.000003") AS Time; SELECT ADDTIME("2019-06-15 05:30:20.000001","2:10:5.000003") AS Time; SELECT ADDTIME("2019-06-15 05:30:20.000001","5 2:10:5.000003") AS Time; SELECT SUBTIME("2019-06-15 05:30:20.000001","5 2:10:5.000003") AS Time; SELECT MAKETIME(16,15,20) AS Time; SELECT TIMESTAMP("2019-06-...

MySQL Date Functions-||

Image
   How to work Date Functions in MySql: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); Examples: SELECT ADDDATE("2019-06-15",I...

MySQL Date Functions

Image
 How to work Date Functions in MySql: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); Examples: SELECT CURRENT_DATE(); SELECT CURDATE(); ...

MySQL String Functions - II

Image
 How to work List of String Function-||: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); Examples: SELECT SUBSTRING("Yahoo Baba...

MySQL String Functions

Image
 How to work List of String Function in MySql: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); String Functions SELECT id , UPPER ( nam...

MySQL Arithmetic Functions

Image
 How to work Arithmetic Functions: Code: CREATE TABLE personal( id INT NOT NULL, name VARCHAR(50) NOT NULL,     percentage INT NOT NULL, age INT NOT NULL, gender VARCHAR(1) NOT NULL, city INT NOT NULL,     courses INT NOT NULL,     PRIMARY KEY (id), FOREIGN KEY (city) REFERENCES City (cid),     FOREIGN KEY (courses) REFERENCES Courses (course_id)   ); INSERT INTO personal(id,name,percentage,age,gender,city,courses) VALUES (1,"Aqib","45","13","M",1,1), (2,"Khadija","56","21","F",2,2), (3,"Salman Khan","62","20","M",1,1), (4,"Aqeela","47","18","F",3,1), (5,"Saqib","74","22","M",1,3), (6,"Abraham","64","21","M",2,2), (7,"Shahid","52","20","M",1,3); Arithmetic Functions SELECT 5 + 6 ; SELECT 5 + ...