Need help with adding a phone number based on cell phone or work number. So in the table phone I have type which is cellphone or workphone some have both. Need to allow this query to allow both. I have it working by pulling only one number, but need to pull both based on type.
You'll see in screen-shot a table example of entry_id are the same meaning same person, but need to query and echo the type with the number. The current query is only pulling one number regardless of what it is.
elseif (isset($individual)) {
$person = <<<SQL
SELECT w.first_name, w.last_name, w.slug, w.options,
w_phone.number, w_email.address, w_address.line_1, w_address.city, w_address.state, w_address.zipcode
FROM wp_connections w INNER JOIN wp_connections_address w_address
ON w.id = w_address.entry_id LEFT JOIN wp_connections_phone w_phone
ON w.id = w_phone.entry_id LEFT JOIN wp_connections_email w_email
ON w.id = w_email.entry_id
WHERE
w.first_name = '$individual' OR
w.last_name = '$individual' OR
w_address.state = '$individual' OR
w_address.city = '$individual' OR
w_address.zipcode = '$individual'
GROUP BY w.id
ORDER BY RAND()
SQL;
}
Here is link to drop box with images of table structure: https://www.dropbox.com/sh/ep0z6yn6sd3mqmu/AAAA-OrNq6QPWtISdxwTeGJZa?dl=0
I need to pull this information out: slug, first_name, last_name from wp_connections
line_1, line_2, city, state, zipcode from from wp_connections_address
type, number from wp_connections_phone but need to get get both types(workphone, cellphone) if person has both.
Keep in mind that in wp_connections the id matches order_id in other tables.