Re: [PHP-DB] Grouping functions inside WHERE clause - may or not
10x Paul - i know that this is a PHP list, but PHPMySQL are almost like husbands already:-)) In addition - in this list are being posted many mysql questions, right? It is PHP.DB... My purpose was to get results with one query only. If expr is a TIMESTAMP, DATE, or DATETIME column, MIN() and MAX() are formatted to the same format if they are constants. +, i still do not understand above passage from MySQL manual have a nice day... Paul Dubois [EMAIL PROTECTED] wrote in message news:p04330106b791e5e07dfd@[192.168.1.31]... At 6:59 PM +0300 8/4/01, Ventsyslav Vassilev wrote: Hi, My simple question is: May i use grouping functions in the WHERE clause of a SQL query in mySQL? For example, this failed to work: SELECT date_field FROM tablename WHERE date_filed BETWEEN MIN(date_field) AND MAX(date_field); In the mySQL manual i red the following into Functions to use in SELECT and WHERE clauses/Comparision operators section: If expr is a TIMESTAMP, DATE, or DATETIME column, MIN() and MAX() are formatted to the same format if they are constants. What this means? may i use min()/max() into WHERE or not? 1) The WHERE clause is used to determine which records to select. 2) MIN() and MAX() are determined based on the values of the selected records. You draw the conclusion. However, you may be able to use user-defined variables to do what you want. Execute a couple of queries: SELECT @dmin := MIN(date_field), @dmax := MAX(date_field) FROM tablename; SELECT date_field FROM tablename WHERE date_field BETWEEN @dmin and @dmax; By the way, this is a PHP list. What's your PHP question? Pls help! -- Ventsyslav Vassilev Comel Soft Multimedia Sofia, Bulgaria ICQ UIN: 11199819 e-mail: [EMAIL PROTECTED] -- Paul DuBois, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Grouping functions inside WHERE clause - may or not
Hi, My simple question is: May i use grouping functions in the WHERE clause of a SQL query in mySQL? For example, this failed to work: SELECT date_field FROM tablename WHERE date_filed BETWEEN MIN(date_field) AND MAX(date_field); In the mySQL manual i red the following into Functions to use in SELECT and WHERE clauses/Comparision operators section: If expr is a TIMESTAMP, DATE, or DATETIME column, MIN() and MAX() are formatted to the same format if they are constants. What this means? may i use min()/max() into WHERE or not? Pls help! -- Ventsyslav Vassilev Comel Soft Multimedia Sofia, Bulgaria ICQ UIN: 11199819 e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Grouping functions inside WHERE clause - may or not
At 6:59 PM +0300 8/4/01, Ventsyslav Vassilev wrote: Hi, My simple question is: May i use grouping functions in the WHERE clause of a SQL query in mySQL? For example, this failed to work: SELECT date_field FROM tablename WHERE date_filed BETWEEN MIN(date_field) AND MAX(date_field); In the mySQL manual i red the following into Functions to use in SELECT and WHERE clauses/Comparision operators section: If expr is a TIMESTAMP, DATE, or DATETIME column, MIN() and MAX() are formatted to the same format if they are constants. What this means? may i use min()/max() into WHERE or not? 1) The WHERE clause is used to determine which records to select. 2) MIN() and MAX() are determined based on the values of the selected records. You draw the conclusion. However, you may be able to use user-defined variables to do what you want. Execute a couple of queries: SELECT @dmin := MIN(date_field), @dmax := MAX(date_field) FROM tablename; SELECT date_field FROM tablename WHERE date_field BETWEEN @dmin and @dmax; By the way, this is a PHP list. What's your PHP question? Pls help! -- Ventsyslav Vassilev Comel Soft Multimedia Sofia, Bulgaria ICQ UIN: 11199819 e-mail: [EMAIL PROTECTED] -- Paul DuBois, [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]