I have a query to pull some records from a database - using a few tables to tie agent names to their sales. My problem is - the agent phone_id and agent first_name and last_name isn't always in the database. For those values I'd like to populate "unknown" for their first and last name. My query as it exists today - just skips them as they don't match.
select recordings.ident,users.first_name,users.last_name,recordings.agent_number,recordings.device_id from recordings
join agent_phones
on recordings.agent_number=agent_phones.phone_id
join users
on agent_phones.agent_id=users.uid
is there a way to do some sort of "if" in the query? so that "if" the agent_number doesn't exist in agent_phones - i can just populate the first_name and last_name with the static "unknown".
Aucun commentaire:
Enregistrer un commentaire