CDbCommand 无法执行 SQL 语句:SQLSTATE[42S22]:未找到列:1054 ‘order 子句’中的未知列‘update_time’。
执行的SQL语句是:
SELECT `t`.`id` AS `t0_c0`,
`t`.`title` AS `t0_c1`,
`t`.`content` AS `t0_c2`,
`t`.`status` AS `t0_c3`,
`t`.`tags` AS `t0_c4`,
`t`.` update_time` AS `t0_c5`,
`t`.`create_time` AS `t0_c6`,
`t`.`author_id` AS `t0_c7`
FROM `post` `t`
WHERE (status=2)
ORDER BY update_time DESC
LIMIT 10
最佳答案
尝试通过别名引用该列:
SELECT `t`.`id` AS `t0_c0`,
`t`.`title` AS `t0_c1`,
`t`.`content` AS `t0_c2`,
`t`.`status` AS `t0_c3`,
`t`.`tags` AS `t0_c4`,
`t`.`update_time` AS `t0_c5`,
`t`.`create_time` AS `t0_c6`,
`t`.`author_id` AS `t0_c7`
FROM `post` `t`
WHERE (`t`.`status`=2)
ORDER BY `t`.`update_time` DESC
LIMIT 10
关于mysql - 显示连接数据库错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23536800/