[EMAIL PROTECTED] wrote on 04/26/2005 09:46:37 AM:

> Hello,
> 
> I have a big problem, I only want to check if it's the minute 45 
> currently.
> 
> I want to make a virtual SELECT without tables:
> 
> mysql> SELECT MINUTE(CURRENT_TIMESTAMP()) WHERE 
> MINUTE(CURRENT_TIMESTAMP()) = 45;
> ERROR 1064 (42000): You have an error in your SQL syntax; check the 
> manual that corresponds to your MySQL server version for the right 
> syntax to use near 'WHERE MINUTE(CURRENT_TIMESTAMP()) = 45' at line 1
> mysql> 
> 
> It works only when I put a FROM with an existing table on it.
> Is there a solution to do it without FROM or to use a virtual table?
> 
> Thanks in advance for your help.
> -- 
> Best regards,
> Stephan Ferraro
> NOOFS - Network Object Oriented File System for UNIX platforms.
> Core Developper - http://noofs.com/
> GnuPG public key: gpg --keyserver www.keyserver.net --recv-key 94B2664F
> 

There are several ways to approach this. My preferred method (because it 
is less version dependent) is to do your logical comparison AS your SELECT 
term and check for 0 or 1 as a result in your code

SELECT (MINUTE(CURRENT_TIMESTAMP())=45);

However, if you are stuck using the "full" select statement try "FROM 
Dual". It's a compatibility enhancement (I think to keep converted Oracle 
code working) that was added in of 4.1.0.

SELECT MINUTE(CURRENT_TIMESTAMP()) 
FROM dual
WHERE MINUTE(CURRENT_TIMESTAMP()) = 45;
(http://dev.mysql.com/doc/mysql/en/select.html)

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

Reply via email to