homepage Welcome to WebmasterWorld Guest from 54.166.65.9
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
simple join query with <> sign not working
mysql 3.23
zeeshan_kh




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

Hey

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

USERS
user_id int
user_name varchar(200)

USER_REMOVE_SEARCH
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
where
u.user_id<>7
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?

 

uncle_bob




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




msg:1245546
 11:31 am on Jan 9, 2006 (gmt 0)

They both work in mysql. I have tried them in a simple query but its just not working in this join...:(

coopster




msg:1245547
 3:59 pm on Jan 9, 2006 (gmt 0)

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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved