So @Demerit's answer above was exactly what I needed to understand how to connect the two tables together (email table and contact info table). I am posting my answer for other noobs that are trying to understand how this works.
In my question I was trying to GET CONTACT info first with the matching email address, however this appears to be far more complex than Demerit's solution which was to GET EMAIL info first with matching contact info... I am sure there is a way to do the complex call, but the exact query that I was looking for in my question above is this (get the email and then its matching contact info):
$emails = civicrm_api4('Email', 'get', [
'select' => [
'*',
'contact_id.*',
],
'where' => [
['email', '=', '[email protected]'],
['contact_id.last_name', 'LIKE', '%smith%'],
['contact_id.is_deleted', '=', FALSE],
],
]);
The SELECT statement *
pulls all the fields from the email table, and then the SELECT statement contact_id.*
pulls all the fields from the related contact table.
The WHERE clause is looking for an email exact match in the email table, with a last_name that contains 'smith' from the related contact table.
Note for 'contains' to work properly, you need to use the LIKE operator, and then wrap your search term in between percent signs '%smith%'. Percent sign is like a wildcard in MySQL. So BEGINS WITH would be LIKE 'smith%' and ENDS WITH would be LIKE '%smith'.
Also note that when you delete a contact, it is not actually deleted from the database (a flag is set that says is_deleted=true), so if you want to ignore deleted contacts you can include a check for is_deleted being false.