List:General Discussion« Previous MessageNext Message »
From:brian Date:June 15 2010 1:13am
Subject:alias problem and odd warnings
View as plain text  
Using 5.1.41/Ubuntu

I have 2 tables, members & countries. The former has a column, 
country_id (tinyint(3) unsigned). The countries id column is the same 
(although auto_increment). I'm trying to select just those countries for 
which there is a member. So I decided this query should do the trick:

SELECT c.id, c.name FROM countries AS c INNER JOIN members AS m ON 
m.country_id = c.id GROUP BY c.id;

And, indeed, it works like a charm. However, I'm using the CakePHP 
framework, which creates a query like:

SELECT `Country`.`id`, `Country`.`name` FROM `countries` AS `Country` 
INNER JOIN members AS `Member` ON `Member`.`country_id` = 'Country.id' 
WHERE 1 = 1 GROUP BY `Country`.`id`;

This not only gives an empty set, but also throws 171 warnings (more on 
that below). I've remove both the WHERE and GROUP BY clauses with no 
success. I've been staring at this for an hour now and can't see what 
the trouble is. Can any of you?


As for the warnings:

Warning | 1292 | Truncated incorrect DOUBLE value: 'Country.id'

I've searched online a bit without success. There was a submitted bug:

http://bugs.mysql.com/bug.php?id=46641

... but I haven't been able to figure anything out based on that (except 
to agree that this error "message" is definitely not very enlightening). 
Can anyone shed some light?

Thread
alias problem and odd warningsbrian15 Jun
  • Re: alias problem and odd warningsbrian15 Jun
    • Re: alias problem and odd warningsJoerg Bruehe15 Jun