Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

simple join query with <> sign not working

mysql 3.23

11:21 am on Jan 9, 2006 (gmt 0)

New User

10+ Year Member

joined:Sept 22, 2005
votes: 0


i'm using mysql 3.23 for my DB. I am trying to run a simple mysql query with a join. Although i'm normally good at joins but for some reason i cant get this query to work and its just a simple join.

right have a users table

user_id int
user_name varchar(200)

user_id int
rem_user_id int

i just want all users from users table except 7 the one's that user_id 7 deleted from his search and now exist in user_remove_search table

this is the query that i'm using

select distinct u.*
from users u, user_remove_search urs
AND (urs.user_id=7 and u.user_id!= urs.rem_user_id)

when i run the query is shows me all the results from users table including the one's that exist in user_remove_search table again user_id 7.

anyone got any idea why this is happening?

11:26 am on Jan 9, 2006 (gmt 0)

Full Member

10+ Year Member

joined:Dec 11, 2003
votes: 0

Shouldn't it be!=7 rather than <>7? I thought it was only msaccess where <> worked.
11:31 am on Jan 9, 2006 (gmt 0)

New User

10+ Year Member

joined:Sept 22, 2005
votes: 0

They both work in mysql. I have tried them in a simple query but its just not working in this join...:(
3:59 pm on Jan 9, 2006 (gmt 0)


WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
votes: 2

It is often easier to understand and help if you give a picture of the data and a picture of the desired results. Can you show a small example of what the data might look like in each of the tables and then a final listing example showing what you want returned?