Mysql Adv Notes-1
Mysql Adv Notes-1
INNER JOIN
LEFT JOIN
The LEFT JOIN command returns all
rows from the left table, and the
matching rows from the right table.
The result is NULL from the right side, if
there is no.
RIGHT JOIN
('krish','manager','2019-09-10'),
('Moses','hr','2019-09-10'),
('Joyal','ACC','2019-09-11'),
('John','sales','2019-09-23'),
('daniel','sales','2019-10-02');
4. create table salary(sid int not null auto_increment,id int not null,sdate date not null,amt int
not null,primary key(sid));
5. insert into salary(id,sdate,amt) values
(1,'2019-09-30',10000),
(2,'2019-09-30',7500),
(3,'2019-09-30',6000),
(4,'2019-09-30',4000);
In above able we have inserted details for 4-employees , the 5 th employee DOJ is 2019-10-02 .. so
we can filtered it using some joins commands
While using joins we want to mention dot operator as prefix in each fields of the table like
Result:
Id Id
Name DesSdate DOJ Amt
2 Moses HR 2019-09-10
Sid
1 1 2019-09-30 10000
2 2 2019-09-30 7500
3 3 2019-09-30 6000
4 4 2019-09-30 4000
Emp.id = salary.id
Id
Id
RESULT
FIND “sep” month updated salary details (LEFT join)
RIGHT JOIN
in above right join result and inner join result both are giving same result , just you can update
another salary details in “Salary” table , then you can view the different result .
Now we got 5th record without having Sdate and Amt because he joined on 2019-10-02
14. select *from students;
15. select *from attendance;
16. select students.name,attendance.ADATE,attendance.ASTATUS from students inner join
attendance on students.id=attendance.id;
CASE
ELSE 0
END
CASE
ELSE 0
END
CASE
ELSE 0
END