Page 1 of 1
[SOLVED] Having multiple conditions in search query
Posted: Thu Jun 01, 2006 3:34 pm
by Milan
can i have a multiple AND conditions in a query for example if i have
Code: Select all
$sql = "SELECT time, dates,events, dayofmonth(dates) as days FROM pickageek.calendar WHERE MONTH(dates)='$month' AND YEAR(dates)='$year'";
can this also work as
Code: Select all
$sql = "SELECT time, dates,events, dayofmonth(dates) as days FROM pickageek.calendar WHERE MONTH(dates)='$month' AND YEAR(dates)='$year' AND user='USERNAME'";
Re: having multiple conditions in search query
Posted: Thu Jun 01, 2006 3:42 pm
by PrObLeM
yes
Posted: Thu Jun 01, 2006 3:43 pm
by Milan
fast and sharp!
thanks!
Posted: Thu Jun 01, 2006 3:43 pm
by daedalus__
edit: i started writing this before those other responses
What?
Code: Select all
$sql = sprintf("
SELECT time, dates, events, dayofmonth(dates) as days
FROM pickageek.calendar
WHERE MONTH(dates) = '%s' AND YEAR(dates) = '%s' AND user = '%s'
", mysql_real_escape_string($month),
mysql_real_escape_string($year),
mysql_real_escape_string($username));
Posted: Thu Jun 01, 2006 3:47 pm
by PrObLeM
Daedalus- wrote:edit: i started writing this before those other responses
What?
Code: Select all
$sql = sprintf("
SELECT time, dates, events, dayofmonth(dates) as days
FROM pickageek.calendar
WHERE MONTH(dates) = '%s' AND YEAR(dates) = '%s' AND user = '%s'
", mysql_real_escape_string($month),
mysql_real_escape_string($year),
mysql_real_escape_string($username));
I think you're in the wrong tread little buddy.
viewtopic.php?t=49424
Posted: Thu Jun 01, 2006 3:48 pm
by Milan
THANKS!
you people are REALY helpfull. Cant wait to finish the website and show you how much can be done with your help.
Posted: Thu Jun 01, 2006 4:45 pm
by daedalus__
I think that I was trying to help him out and I also think that I don't need sarcastic comments from you.
That's just my opinion though.
Just in case you really think that I posted in the wrong thread, I take that back.
Posted: Thu Jun 01, 2006 4:48 pm
by PrObLeM
Daedalus- wrote:
Just in case you really think that I posted in the wrong thread, I take that back.
yea I'm sorry too, the code you posted looked like it was from the other tread so I thought it was a misspost
Posted: Thu Jun 01, 2006 5:19 pm
by daedalus__
Well, that's my method when I need to include a WHERE clause.
I do it everywhere.