SQL JOIN Variable
I have tables:
tasks
id
name
description
parent_id
parent_type
accounts
id
name
leads
id
name
My query that works looks
SELECT tasks.name,date_due, tasks.description, accounts.name FROM tasks
JOIN accounts
on tasks.parent_id = accounts.id
WHERE DATE(date_due) = DATE(NOW() + INTERVAL 1 DAY) AND
tasks.assigned_user_id=1
What I need is to make the accounts a variable - it can be either accounts
or leads, depends on the tasks.parent_type value.
Any tips how to achieve this?
No comments:
Post a Comment