Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inner joining two tables returns empty result

Tags:

sql

I am trying to get two tables that aren't related to pull a column of data each.

I have one table called AlphaData and one called TLAuth. Each includes a column that is labelled invoice and I need to pull both columns so I can at least start a comparison. TLAuth will include some of the invoice numbers from AlphaData, but not all of them.

Right now I am using the following code:

SELECT Alphadata.Invoice, TLAuth.Invoice
FROM Alphadata
INNER JOIN TlAuth
ON TLauth.TLAUthID = Alphadata.TLAUthID;

But every time I run this it comes up totally blank. There is definitely data in there, I can pull one column of data from each, but not both at the same time. I have even setup a relationship (1 to Many from TL Auth to Alphadata) and it doesn't seem to work so any help would be grand.

like image 862
Nik Avatar asked May 12 '26 18:05

Nik


1 Answers

If the tables could not match you should use left join

SELECT Alphadata.Invoice, TLAuth.Invoice
From Alphadata
LEFT JOIN TlAuth ON TLauth.TLAUthID=Alphadata.TLAUthID;
like image 164
ScaisEdge Avatar answered May 15 '26 06:05

ScaisEdge