** Oops sorry I named the thread the wrong thing on accident, lol **
I’m not sure how to get this working, I might have to do 2 queries.
Does this make sense what I’m trying to do? I don’t know if INNER JOIN is the way to go about this, I am stuck because of the WHERE statement.
SELECT p.*
FROM projects AS p
INNER JOIN project_assigned_users
AS pu
ON (
pu.assign_user = '5'
AND
pu.assign_project = p.id
)
-- This WHERE statement ruins it...
-- I'd like it to say, "OR WHERE"
WHERE assign_customer = '1'
ORDER BY current_state ASC
I’m trying to select Projects for a user:
1: if they are inside the project_assigned_user table
2: OR if they are the projects default customer (on the project table)
SELECT p.*
FROM projects AS p
INNER JOIN project_assigned_users AS pu
ON pu.assign_project = p.id
WHERE pu.assign_user = '5'
UNION
SELECT *
FROM projects
WHERE assign_customer = '1'
ORDER BY current_state ASC
I guess SELECT DISTINCT would be irrelevant with UNION since there would be two separate selects. This books got a lot of stuff to keep going back to – I think I know something, then I realize I only know a little, haha…