Skip to content
Advertisement

SELECT from table where id is not represented with another user_id

I’m trying to select rows, where the id_imported_urls is only present on the current user, but i cant figure out how to make the SQL call properly.

Advertisement

Answer

With NOT EXISTS:

This will return a row only if id_imported_urls = 23965 does not exist for any user_id <> 4 .
This query:

returns all the id_imported_urls that belong to only 1 user, so you can use it like this:

to get all the rows that contain these id_imported_urls.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement