Opposite INNER JOIN with EXIST requirement

If an inner join requires a string to exist, what is the opposite of it without doing a sub-query NOT EXISTS?

I replaced

 AND NOT EXISTS (
  SELECT
   *
  FROM topic_read_assoc
  WHERE topic_id = topic.id
   AND member_id = ".$this->tru->application->currentMember->getId()."
 )

with

OUTER JOIN topic_read_assoc ON (
 topic_read_assoc.topic_id = topic.id AND
 member_id = member_id = ".$this->tru->application->currentMember->getId()."
)

and it does not give the same results as the first query (which works)

+5
source share
2 answers

OUTER JOIN with a WHERE field IS NULL

Example:

SELECT A.name FROM A INNER JOIN B on A.id = B.id

Select those names in A whose id fields exist in B

On the contrary:

SELECT A.name FROM A OUTER JOIN B on A.id = B.id WHERE B.id IS NULL

Select those names in A whose id does not exist in B

+10
source

, , dbms , . , , . , .

-1

All Articles