Table Join - Baffled

Hi,

I have two tables i need to query at the same time.

SELECT * FROM `tblinspectiondata` WHERE `SolicitorID` = :solid AND `iStatus` = 'Complete'
SELECT * FROM `tblreportdata` WHERE `Waived` = '0' AND `Paid` = '0'  AND 'Cancelled' = '0'

Both have a mutual column called LairdRef

So the idea is to get results of all LairdRef that are set as complete and paid & cancelled & waived that all equal 0.

Sorry hope this is clear enough.

I have a feeling of deja-vu… This sounds familiar somehow…

Anyway, simply do an INNER JOIN. An INNER JOIN will bring those records that have a the same value in the common field, in this case LairdRef

In your case

SELECT * FROM tblinspeCtiondata as t1 INNER JOIN tblreportdata as t2 ON  t1.LairdRef=t2.LairdRef WHERE Waived = 0 AND Paid = 0  AND Cancelled = 0;

I used aliases for the tables because they’re (the names, that is) a bit long to write and in this way it is easier to not make spelling mistakes (at least, in my case)

Thank you for your help :slight_smile:

[quote=“molona, post:2, topic:111112, full:true”]
I have a feeling of deja-vu… [/quote]
moi aussi

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.