I want 'hidden ranks' on my employee page

63 views Asked by At

Okay, so my English is not that good and my PHP skills are even worse. It'll be exciting to see if anyone even get what I so desperately need help with.

So I have 11 ranks in my MySQL database. Administrator, super moderator, moderator, etc..

I'm using the SELECT statement in my employee web page. It looks something like this:

SELECT id,name FROM ranks WHERE id = '5' AND id = '10' ORDER BY id DESC

It doesn't work. What I want to do is to only show employees ranked either 5 or 10. No other rank should appear on this page. What do I do?

Thanks in advance! :-)

2

There are 2 answers

5
jacob_b On BEST ANSWER

The issue is you used AND instead of OR what you need to be doing is

SELECT id,name FROM ranks WHERE id = '5' OR id = '10' ORDER BY id DESC

edit otherwise it will be looking for a user with the rank 5 and 10.

0
Saharsh Shah On

Try this:

SELECT r.id, r.name 
FROM ranks r
WHERE r.id IN (5, 10) 
ORDER BY r.id DESC