I have 2 tables: files and user.
files
----------------------------
|Fileid | name | type |
----------------------------
| 01 | file1 | private |
| 02 | file2 | private |
| 03 | file3 | Public |
----------------------------
and
user
---------------------
| Fileid | UserId |
---------------------
| 01 | user1 |
| 02 | user1 |
---------------------
How would I select all the record(private and public) for who ever id is in the ‘user’ table and only ‘public’ files for any other user where the ‘userid’ is not in the ‘user’ table? please help
If I correctly understand the problem, you are looking for a
LEFT JOINfavoringfilesreturning all fields for non-nullUserId, orPubliconly whenUserId IS NULL.