提示字段不存在。

「已注销」 2013-07-09 10:54:40
select p1.*,p6.isqiye,p6.id as fastid,
p2.username,p2.area as user_area ,
u.username as kefu_username,
p2.qq,p3.value as credit_jifen,
p4.pic as credit_pic,
p5.area as add_area,
p1.account_yes/p1.account as scales from `dw_borrow` as p1
left join `dw_user` as p2 on p1.user_id=p2.user_id
left join `dw_user_cache` as uca on uca.user_id=p1.user_id
left join `dw_user` as u on u.user_id=uca.kefu_userid
left join `dw_credit` as p3 on p1.user_id=p3.user_id
left join `dw_credit_rank` as p4 on p3.value<=p4.point2 and p3.value>=p4.point1
left join `dw_userinfo` as p5 on p1.user_id=p5.user_id
left join `dw_daizi` as p6 on p1.id=p6.borrow_id
where 1=1 and (p1.status=1 or p1.status=3) and p1.scales=1
order by p1.id
desc limit 0, 10

提示unknown column p1.`scales` in `where clause`
但我在生成的表里面有scales这个字段啊。
这是为什么?
...全文
606 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
「已注销」 2013-07-09
  • 打赏
  • 举报
回复
引用 6 楼 rucypli 的回复:
不能这么写 改成 select * from ( select p1.*,p6.isqiye,p6.id as fastid, p2.username,p2.area as user_area , u.username as kefu_username, p2.qq,p3.value as credit_jifen, p4.pic as credit_pic, p5.area as add_area, p1.account_yes/p1.account as scales from `dw_borrow` as p1 left join `dw_user` as p2 on p1.user_id=p2.user_id left join `dw_user_cache` as uca on uca.user_id=p1.user_id left join `dw_user` as u on u.user_id=uca.kefu_userid left join `dw_credit` as p3 on p1.user_id=p3.user_id left join `dw_credit_rank` as p4 on p3.value<=p4.point2 and p3.value>=p4.point1 left join `dw_userinfo` as p5 on p1.user_id=p5.user_id left join `dw_daizi` as p6 on p1.id=p6.borrow_id where 1=1 and (p1.status=1 or p1.status=3) )tmp where scales=1 order by id desc limit 0, 10;
谢谢。
rucypli 2013-07-09
  • 打赏
  • 举报
回复
不能这么写 改成 select * from ( select p1.*,p6.isqiye,p6.id as fastid, p2.username,p2.area as user_area , u.username as kefu_username, p2.qq,p3.value as credit_jifen, p4.pic as credit_pic, p5.area as add_area, p1.account_yes/p1.account as scales from `dw_borrow` as p1 left join `dw_user` as p2 on p1.user_id=p2.user_id left join `dw_user_cache` as uca on uca.user_id=p1.user_id left join `dw_user` as u on u.user_id=uca.kefu_userid left join `dw_credit` as p3 on p1.user_id=p3.user_id left join `dw_credit_rank` as p4 on p3.value<=p4.point2 and p3.value>=p4.point1 left join `dw_userinfo` as p5 on p1.user_id=p5.user_id left join `dw_daizi` as p6 on p1.id=p6.borrow_id where 1=1 and (p1.status=1 or p1.status=3) )tmp where scales=1 order by id desc limit 0, 10;
「已注销」 2013-07-09
  • 打赏
  • 举报
回复
引用 4 楼 wwwwb 的回复:
[quote=引用 2 楼 lldszy 的回复:] [quote=引用 1 楼 wwwwb 的回复:] show create table dw_borrow
原来的字段里没有scales这个字段,而是使用运算后,as生成的。[/quote] 提问也是有技巧的,从你提问给出的SQL语句没有看出scales是用运算后,as生成的[/quote] 有吧
select p1.*,p6.isqiye,p6.id as fastid,
p2.username,p2.area as user_area ,
u.username as kefu_username,
p2.qq,p3.value as credit_jifen,
p4.pic as credit_pic,
p5.area as add_area,
p1.account_yes/p1.account as scales
wwwwb 2013-07-09
  • 打赏
  • 举报
回复
引用 2 楼 lldszy 的回复:
[quote=引用 1 楼 wwwwb 的回复:] show create table dw_borrow
原来的字段里没有scales这个字段,而是使用运算后,as生成的。[/quote] 提问也是有技巧的,从你提问给出的SQL语句没有看出scales是用运算后,as生成的
「已注销」 2013-07-09
  • 打赏
  • 举报
回复
CREATE TABLE `dw_borrow` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `site_id` int(11) DEFAULT '0' COMMENT '所属站点',
  `user_id` int(11) DEFAULT '0' COMMENT '用户名称',
  `name` varchar(255) DEFAULT NULL COMMENT '标题',
  `status` int(2) DEFAULT '0' COMMENT '状态',
  `order` int(11) DEFAULT '0' COMMENT '排序',
  `hits` int(11) DEFAULT '0' COMMENT '点击次数',
  `litpic` varchar(255) DEFAULT NULL COMMENT '缩略图',
  `flag` varchar(50) DEFAULT NULL COMMENT '属性',
  `is_vouch` int(2) NOT NULL,
  `type` varchar(50) NOT NULL,
  `view_type` int(11) NOT NULL,
  `vouch_award` varchar(40) NOT NULL,
  `vouch_user` varchar(100) NOT NULL,
  `vouch_account` varchar(50) NOT NULL,
  `vouch_times` int(11) NOT NULL DEFAULT '0',
  `source` varchar(50) DEFAULT NULL COMMENT '来源',
  `publish` varchar(50) DEFAULT NULL COMMENT '发布时间',
  `customer` varchar(11) DEFAULT NULL COMMENT '客服',
  `number_id` varchar(50) DEFAULT NULL,
  `verify_user` varchar(11) DEFAULT NULL COMMENT '审核人',
  `verify_time` varchar(50) DEFAULT NULL COMMENT '客服',
  `verify_remark` varchar(255) DEFAULT NULL,
  `repayment_user` int(11) DEFAULT '0',
  `forst_account` varchar(50) DEFAULT '0',
  `repayment_account` varchar(50) DEFAULT NULL,
  `monthly_repayment` varchar(50) DEFAULT NULL COMMENT '每月还款额',
  `repayment_yesaccount` varchar(50) DEFAULT '0',
  `repayment_yesinterest` int(11) NOT NULL,
  `repayment_time` varchar(50) DEFAULT NULL,
  `repayment_remark` varchar(250) DEFAULT NULL,
  `success_time` varchar(50) DEFAULT NULL,
  `end_time` varchar(50) DEFAULT NULL,
  `payment_account` varchar(50) DEFAULT NULL,
  `each_time` varchar(50) DEFAULT NULL,
  `use` varchar(50) DEFAULT NULL COMMENT '用途',
  `time_limit` varchar(50) DEFAULT NULL COMMENT '借款期限',
  `style` varchar(50) DEFAULT NULL COMMENT '还款方式',
  `account` varchar(50) DEFAULT NULL COMMENT '借贷总金额',
  `account_yes` varchar(10) DEFAULT '0',
  `tender_times` varchar(11) DEFAULT '0',
  `apr` decimal(18,2) DEFAULT NULL COMMENT '年利率',
  `lowest_account` varchar(50) DEFAULT NULL COMMENT '最低投标金额',
  `most_account` varchar(50) DEFAULT NULL COMMENT '最多投标总额',
  `valid_time` varchar(50) DEFAULT NULL COMMENT '有效时间',
  `award` varchar(50) DEFAULT NULL COMMENT '投标奖励',
  `part_account` varchar(50) DEFAULT NULL COMMENT '分摊奖励金额',
  `funds` varchar(50) DEFAULT NULL COMMENT '比例奖励的比例',
  `is_false` varchar(50) DEFAULT NULL COMMENT '标的失败时也同样奖励 ',
  `open_account` varchar(50) DEFAULT NULL COMMENT '公开我的帐户资金情况',
  `open_borrow` varchar(50) DEFAULT NULL COMMENT '公开我的借款资金情况',
  `open_tender` varchar(50) DEFAULT NULL COMMENT '公开我的投标资金情况',
  `open_credit` varchar(50) DEFAULT NULL COMMENT '公开我的信用额度情况',
  `content` text COMMENT '详细说明',
  `addtime` varchar(50) DEFAULT NULL,
  `addip` varchar(50) DEFAULT NULL,
  `is_do` int(1) NOT NULL DEFAULT '0',
  `is_mb` int(1) NOT NULL,
  `is_fast` int(11) NOT NULL,
  `is_jin` int(1) NOT NULL DEFAULT '0',
  `cz_old_id` int(11) unsigned NOT NULL DEFAULT '0',
  `jiaoyan` int(2) NOT NULL DEFAULT '0',
  `is_cz` int(1) unsigned NOT NULL DEFAULT '0',
  `is_dxb` int(1) NOT NULL DEFAULT '0',
  `pwd` varchar(20) DEFAULT NULL,
  `isday` int(1) NOT NULL DEFAULT '0',
  `time_limit_day` varchar(50) DEFAULT NULL,
  `old_loanee` varchar(50) DEFAULT NULL,
  `old_date` date DEFAULT NULL,
  `old_time` int(4) NOT NULL DEFAULT '0',
  `old_apr` int(4) NOT NULL DEFAULT '0',
  `apr_add` int(4) NOT NULL DEFAULT '0',
  `lowest_months` int(4) NOT NULL DEFAULT '0',
  `add_months` int(4) NOT NULL DEFAULT '0',
  `per_account` int(6) NOT NULL DEFAULT '0',
  `max_nums` int(10) NOT NULL DEFAULT '0',
  `is_liuzhuan` int(2) NOT NULL DEFAULT '0',
  `buy_times` int(6) NOT NULL DEFAULT '0',
  `r_nums` int(6) NOT NULL DEFAULT '0',
  `r_months` int(6) NOT NULL DEFAULT '0',
  `jiang` int(11) NOT NULL DEFAULT '0',
  `is_dsm` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `user_ids` (`user_id`,`status`),
  KEY `user_idst` (`status`)
) ENGINE=MyISAM AUTO_INCREMENT=617 DEFAULT CHARSET=gbk
「已注销」 2013-07-09
  • 打赏
  • 举报
回复
引用 1 楼 wwwwb 的回复:
show create table dw_borrow
原来的字段里没有scales这个字段,而是使用运算后,as生成的。
wwwwb 2013-07-09
  • 打赏
  • 举报
回复
show create table dw_borrow
「已注销」 2013-07-09
  • 打赏
  • 举报
回复
引用 8 楼 ACMAIN_CHM 的回复:
where 1=1 and (p1.status=1 or p1.status=3) and p1.account_yes/p1.account =1 在做WHERE的时候,p1.account_yes/p1.account as scales 还没有生成。
谢谢。懂了。
ACMAIN_CHM 2013-07-09
  • 打赏
  • 举报
回复
where 1=1 and (p1.status=1 or p1.status=3) and p1.account_yes/p1.account =1 在做WHERE的时候,p1.account_yes/p1.account as scales 还没有生成。

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧