Gregg, Monday, May 06, 2002, 6:57:55 PM, you wrote: GG> Upon reading into the user variables section of the mysql manual, I decided GG> to make my life easier inside several of my queries by specifying some user GG> variables. Note that I'm trying to have everything inside the select GG> statement - Primarily because I'm simply passing it through to my data GG> mining software that interfaces through myODBC.
GG> I'm trying to accomplish the following query (I'm executing these sql GG> queries directly from the command line) -- GG> ============================================================================ GG> == GG> SELECT GG> annual_filing.*, GG> companies.name AS company_name, GG> YEAR(filing_date) AS filing_year, GG> (@predictedYear := 1999) AS predictedYear, GG> (@earliestYear := 1996) AS earliestYear, GG> (@learnYear := 1998) AS learnYear GG> FROM GG> annual_filing, GG> companies GG> WHERE GG> annual_filing.company_id = companies.ds_id GG> AND GG> YEAR(filing_date) <= @predictedYear GG> AND GG> YEAR(filing_date) >= @earliestYear; GG> ============================================================================ GG> == GG> The above query returned an empty set / no rows. You should first initialize user variables! By default they contain NULL values as SELECT works by first checking WHERE clause and only then works for SELECT. Check the manual: http://www.mysql.com/doc/V/a/Variables.html GG> === GG> Gregg Graubins <[EMAIL PROTECTED]> -- For technical support contracts, goto https://order.mysql.com/?ref=ensita This email is sponsored by Ensita.net http://www.ensita.net/ __ ___ ___ ____ __ / |/ /_ __/ __/ __ \/ / Victoria Reznichenko / /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED] /_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.net <___/ www.mysql.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php