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?
**SOLVED** SELECT * FROM users WHERE AND
Moderator: General Moderators
**SOLVED** SELECT * FROM users WHERE AND
Last edited by mikes1471 on Wed Oct 14, 2009 9:06 pm, edited 1 time in total.
Re: SELECT * FROM users WHERE AND
Who is male AND female? 
Re: SELECT * FROM users WHERE AND
Lol I want to select records for both males and females
Re: SELECT * FROM users WHERE AND
... wouldn't that be all of them?
Re: SELECT * FROM users WHERE AND
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
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.
2. There is no "X = A or B" shortcut. You have to spell it out all the way.
Re: SELECT * FROM users WHERE AND
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.
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
Excellent thankyou!!
Re: **SOLVED** SELECT * FROM users WHERE AND
[sql]WHERE gender IS NOT NULL[/sql]
assuming your default state is a NULL value
assuming your default state is a NULL value