Faisal Faisal - 3 months ago 8
MySQL Question

How to retrieve data from two tables using sql?

I have two table 1.Sender_Table,2.Receiver_Table

Sender_Table
Full_Name Id Amount
john 10 50000
Max 22 40000
Arun 11 25000

Receiver_Table
Name City Amount
Michel newyork 3000
john London 20000


i want to retrieve all columns from both table where name = john in both tables.

please help me, thanks

Answer

Use an inner join

select a.Full_name, a.Id, a.Amount, b.City,  b.Amount
from Sender_Table as a
inner join Receiver_Table as b  on a.Full_name = b.Name

.

select a.Full_name,a.Id,  a.Amount, b.City,  b.Amount
from Sender_Table as a
inner join Receiver_Table as b  on a.Full_name = b.Name
where a.Full_name = 'john'