Hi,
I've encountered a problem when deleting rows from my query. I've come up to the following procedure to reproduce the error:
Create two tables and populate them:
CREATE TABLE `test` (
`id` int(11) NOT NULL auto_increment,
`names` varchar(20) default NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `test` VALUES (2,'aaaa');
INSERT INTO `test` VALUES (3,'bbbb');
CREATE TABLE `test2` (
`id` int(11) NOT NULL auto_increment,
`parent_id` int(11) default NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `test2` VALUES (1,2);
INSERT INTO `test2` VALUES (2,3);
INSERT INTO `test2` VALUES (3,2);
Create TMyQuery with the following SQL:
select TC.id,
if(T.id<0,'abc',T.names) as names
from
test2 TC
left join test T on (T.id = TC.parent_id)
order by T.names
Add fields with the `Field Editor`.
Now either use the `Date Editor` in the IDE or launch app and issue MyQuery.Delete - both will result with the same error:
#42S22Unknown column 'names' in 'where clause'
Remove the if clause (or the 'order by') from the SQL query and there will be no error so the query above should also work.
Regards,
Crafty