Question

How can I say in MySQL when I want to select all the typing and user that is online(1) except for one user with the id of 4? and I want the username of id= 4 not the typing

I tried NOT IN but I'm guessing it is not working for me.

SELECT username,typing FROM members WHERE status = 1 NOT IN (SELECT typing FROM members WHERE id =4)

http://img266.imageshack.us/img266/2313/typing.png

click the image for more info

Was it helpful?

Solution

Is this what you want?

SELECT username, 
       (case when id <> 4 then typing end) as typing
FROM members
WHERE status = 1 or id = 4

Based on your image, I think you just want:

SELECT username, typing
FROM members
WHERE status = 1 and id <> 4

OTHER TIPS

I would use a join like this:

SELECT username, typing FROM members members LEFT OUTER JOIN typing typing WHERE members.status = 1 AND typing.id <> 4
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top