Re: Question on CURDATE()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Micah,
Oh, my bad. I was trying to remember how I did something like this before, stringing together a lot of "WHERE"s. You're right, though, it wasn't "WHERE", it was "OR".

Rich,
I think you need "OR" instead of "AND", OR else I'm just totally out to lunch tonight:
SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() OR END <= CURDATE();

The syntax error is that something cannot be >= AND <= the same thing at the same time!

I have had this problem before in the past. You say to yourself, well, I need all of the records, so that intuitively makes you choose "AND" when in SQL it should technically be "OR" (you want the records that are true for each of these operators separately, NOT at the same time, which for most records is impossible).

Also, you may want to take away one of the "=" signs, or you may get something "=" to CURDATE() twice (not sure how SQL handles this).

Maybe try (taking out one of the "="):
SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() OR END < CURDATE();

Maybe it's just late over here. Has anyone else run into this same thing?

Jordan



On Sep 13, 2005, at 10:36 PM, Micah Stevens wrote:


You can't do that in SQL, that would give you a big fat syntax error.

On Tuesday 13 September 2005 7:45 pm, Jordan Miller wrote:

Rich,

Did you try putting "WHERE" twice?

try:
SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and WHERE END <= CURDATE;

Jordan

On Sep 13, 2005, at 9:08 PM, reclmaples wrote:

I am trying to write a statement that will basically do this:

SELECT * FROM WEEKS WHERE BEGIN >= CURDATE() and END <= CURDATE;

But for some reason I can only use one CURDATE() reference in my sql
statement, does anyone know why?  Is there a way I can get around
this?


Any help would be greatly appreciated.

Thanks
-Rich

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux