Page 1 of 1
**SOLVED** SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 7:46 pm
by mikes1471
Hi Everyone
I realise the header makes no sense in the format Ive written it but honestly at this stage Im unsure of the best way to call data from my database
Currently I display a list of user values on my webpage but for records that dont contain a value in 'Gender', theyre still being displayed, I dont want this, so thought I could SELECT * FROM users WHERE gender ="male" AND "female"
Will that work or is there a better way?
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 7:57 pm
by Mirge
Who is male AND female?

Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 8:00 pm
by mikes1471
Lol I want to select records for both males and females
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 8:02 pm
by Griven
... wouldn't that be all of them?
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 8:06 pm
by mikes1471
No, I'm storing all data in one table, this includes image upload data recorded in the database which is simply a datestamp, filename and the location of the file on the webserver , in which case the gender isn't posted
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 8:36 pm
by requinix
1. You don't want rows where the gender is male and female, or want it where it's male or female.
2. There is no "X = A or B" shortcut. You have to spell it out all the way.
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 8:55 pm
by Mirge
SELECT * FROM users WHERE gender='male' OR gender='female';
Or... since those really are the only 2 options..
SELECT * FROM users WHERE LENGTH(gender) > 0;
etc... few different ways you could go at it.
Re: SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 9:04 pm
by mikes1471
Excellent thankyou!!
Re: **SOLVED** SELECT * FROM users WHERE AND
Posted: Wed Oct 14, 2009 9:09 pm
by Eran
[sql]WHERE gender IS NOT NULL[/sql]
assuming your default state is a NULL value