I *think* I've understood your requirement:
SELECT fi.*
FROM files AS fi
WHERE NOT EXISTS
( SELECT 1
FROM files_folders AS ff
, folders AS fo
WHERE ff.folder_id = fo.folder_id
AND fo.user_id = 1
AND ff.file_id = fi.file_id
);
hth
Philip
rpeterson wrote:
> I am trying to figure out how to create a SQL query to
find all files
> that are not joined to a folder. The current tables are
like this.
>
> folders
>
> files_folders - (file_id and folder_id)
>
> files
>
> I am trying to find all files that are not joined to
any folder that
> belongs to user_id , the files however could be jouined
to a folder of
> a different user_id ...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "PHP & MySQL" group.
To post to this group, send email to phpmysql googlegroups.com
To unsubscribe from this group, send email to
phpmysql-unsubscribe googlegroups.com
For more options, visit this group at http://groups
.google.com/group/phpmysql
-~----------~----~----~----~------~----~------~--~---
|