Forum Moderators: coopster

Message Too Old, No Replies

Query where peeps in one table wont be showed

Query where peeps in one table wont be showed

         

Twisted Mind

9:52 am on Jan 19, 2006 (gmt 0)

10+ Year Member



select mos_users.id, mos_users.username, mos_mediaman_acces.userid from mos_users, mos_mediaman_acces WHERE mos_users.id!=mos_mediaman_acces.userid

is my query and it will return with the results from table mos_users as many times as you have some1 in mos_Mediaman_Acces but i dont want this i want 1 result without the people in the table mos_mediaman_acces.

TY for your help IS it not clear? ask and i will speak :D

tomda

10:02 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not really clear!

Is this what you are looking for?
select mos_mediaman_acces.userid, mos_users.id, mos_users.username from mos_mediaman_acces, mos_users WHERE mos_mediaman_acces.userid==mos_users.id;

Otherwise, a bit longer, but you can:
1/ Do a query to get the id of mos_mediaman_access and create an array.
2/ Do a query of all your user and create an array
3/ Work with array (difference, union, etc...) to get what you want

Twisted Mind

10:06 am on Jan 19, 2006 (gmt 0)

10+ Year Member



I dont know what u mean with option 1-2-3 but the query you gave was wrong i see the people in my list that way and i need to see those who are not but if i do!= i get loads of people double and if i had 3 people in my list i get some of them triple!

tomda

10:13 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am used with advanced queries but have some readings about SQL JOIN
[w3schools.com...]

They are great examples and explanation, and also some tips on how to use GROUP_BY.

Also, post an example on how your tables look like so that I can understand the structure you are having.

Good luck

Twisted Mind

10:20 am on Jan 19, 2006 (gmt 0)

10+ Year Member



Tables:
Verry simple actually (users is bigger but tha doesnt matter now)
Users:
¦id¦username¦
mediaman_Acces
¦id¦userid¦

Tahts all :P

Twisted Mind

10:31 am on Jan 19, 2006 (gmt 0)

10+ Year Member



W3 scools dont help me all the querys do the same...

tomda

11:13 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, TwistedMind but I am quite busy.
Also, I am not a MYSQL expert so I can't answer on the fly

Let's hope that someone else will help you out on this one...

Twisted Mind

11:22 am on Jan 19, 2006 (gmt 0)

10+ Year Member



i hope so too :P

Twisted Mind

12:25 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



please anyone?

Twisted Mind

12:58 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



No one knows what i should do with it?

jatar_k

4:39 pm on Jan 19, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't understand what you are trying to do with that query

maybe if you could explain what it is you are trying to select as opposed to a query that doesn't work it would help us to figure it out.

stajer

4:52 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



This is what I think you are trying to do:


select
mos_users.id, mos_users.username
from
mos_users
where
mos_users.id NOT IN
(select distinct userID from mos_mediaman_access)

It returns all mos_users who are not in mos_mediaman_access.

Twisted Mind

5:33 pm on Jan 19, 2006 (gmt 0)

10+ Year Member



if it works that is what i need.

Jakar you should have read my posts before it is clear for other people also thanks anyway :D

Twisted Mind

7:13 am on Jan 20, 2006 (gmt 0)

10+ Year Member



THANKY OOOUUUU