SQL Join--> Inner Join, Full join, Left join, Right join
Table :
Car_owner (c_id, c_name, phone, address)
Car_parking (p_id, position, duration)
Rent (c_id, p_id, charge, date)
1) Find the car owner name who parked his car more than 5 hours?
SQL Query: select Car_owner .c_name
from (( Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id )
INNER JOIN Car_parking ON Rent.p_id = Car_parking.p_id
and Car_parking .duration = 5 );
2) Find the car owner name who parked his car in "21/05/2018"
SQL Query: select Car_owner .c_name
from Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id
and Rent.date = ' 21/05/2018 ';
and Rent.date = ' 21/05/2018 ';
3) Find the car owner all information who parked his car in Dhaka
SQL Query: select *
from (( Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id )
INNER JOIN Car_parking ON Rent.p_id = Car_parking.p_id
and Car_parking .position = ' Dhaka ' );
4) Find the car owner all information who parked his car in Dhaka and duration in 3 hours
SQL Query: select *
from (( Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id )
INNER JOIN Car_parking ON Rent.p_id = Car_parking.p_id
and Car_parking .position = ' Dhaka ' and Car_parking .duration = 3 );
5) Find the car owner all information who parked his car in Dhaka OR duration in 4 hours
SQL Query: select *
from (( Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id )
INNER JOIN Car_parking ON Rent.p_id = Car_parking.p_id
and Car_parking .position = ' Dhaka ' OR Car_parking .duration = 4 );
6) Find the Rent charge where Car_owner name is Rahim
SQL Query: select Rent .charge
from Rent INNER JOIN Car_owner ON Car_owner .c_id = Rent .c_id
and Car_owner .c_name = ' Rahim ';
and Car_owner .c_name = ' Rahim ';
7) Find the car owner all information who parked his car in "10/12/2018"
SQL Query: select *
from Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id
and Rent.date = ' 10/12/2018 ';
8) Find the car owner phone number who parked his car in "Netrokona"
and Rent.date = ' 10/12/2018 ';
8) Find the car owner phone number who parked his car in "Netrokona"
SQL Query: select Car_owner .phone
from (( Car_owner INNER JOIN Rent ON Car_owner .c_id = Rent .c_id )
INNER JOIN Car_parking ON Rent.p_id = Car_parking.p_id
and Car_parking .position = ' Netrokona ' );
9) Find all car owner information and Rent information?
9) Find all car owner information and Rent information?
SQL Query: select *
from Car_owner LEFT JOIN Rent ON Car_owner .c_id = Rent .c_id ;
10) Find all Rent information and Car_owner information?
10) Find all Rent information and Car_owner information?
SQL Query: select *
from Rent LEFT JOIN Car_owner ON Car_owner .c_id = Rent .c_id ;
11) Find Rent information and ALL Car_owner information?
11) Find Rent information and ALL Car_owner information?
SQL Query: select *
from Rent Right JOIN Car_owner ON Car_owner .c_id = Rent .c_id ;
12) Find Car_owner information and ALL Rent information?
12) Find Car_owner information and ALL Rent information?
SQL Query: select *
from Car_owner Right JOIN Rent ON Car_owner .c_id = Rent .c_id ;
13) Find All Car_owner information and ALL Rent information?
13) Find All Car_owner information and ALL Rent information?
SQL Query: select *
from Car_owner FULL JOIN Rent ON Car_owner .c_id = Rent .c_id ;
14) Find Rend position where rend in 500 tk per hour?
14) Find Rend position where rend in 500 tk per hour?
SQL Query: select Car_parking .position
from Car_parking INNER JOIN Rent ON Car_parking .p_id = Rent .p_id
and Rent . charge = 500 ;
15) Find Rend Charge where rend position in Dhaka?
and Rent . charge = 500 ;
15) Find Rend Charge where rend position in Dhaka?
SQL Query: select Rent .charge
from Rent INNER JOIN Car_parking ON Car_parking .p_id = Rent .p_id
and Car_parking.position = ' Dhaka ';
<-- Back Page
and Car_parking.position = ' Dhaka ';
<-- Back Page
0 Comments
If you have any doubts, Please let me know