错误代码: 1066 Not unique table/alias: 'asd'

1、错误描述
sql.append("select cdp.id id,cdp.distributionMapLegend distributionMapLegend,cdp.siteMarker siteMarker, ");
		sql.append("hd.type horizontalAxisUnit,cdp.mapPop mapPop,cdp.searchStrip searchStrip,cdp.isRainsProcessNum isRainsProcessNum, ");
		sql.append("ld.type legendType,p.productName productName,pd.type productType,cdp.requestPath requestPath,cdp.pictureRequestPath pictureRequestPath, " +
				"asd.type isAreaChoice, ssd.type siteType from climate_disaster_product cdp  ");
		sql.append("left join product p on p.productId = cdp.id " +
				"left join sys_dict hd on hd.id = cdp.horizontalAxisUnit " +
				"left join sys_dict ld on ld.id = cdp.legendType  " +
				"left join sys_dict asd on asd.id = cdp.isAreaChoice " +
				"left join sys_dict asd on ssd.id = cdp.siteType " +
				"left join sys_dict pd on pd.id = p.productType ");
		sql.append("where cdp.isDelete = '0' and cdp.publishFlag = '1' and cdp.id=?");

2、错误原因

     在拼接SQL语句时,给sys_dict 取别名时,都取asd

     导致数据库表别名重复


3、解决办法

     将两个表的别名改为不一样的,如ssd

4、解决问题

sql.append("select cdp.id id,cdp.distributionMapLegend distributionMapLegend,cdp.siteMarker siteMarker, ");
		sql.append("hd.type horizontalAxisUnit,cdp.mapPop mapPop,cdp.searchStrip searchStrip,cdp.isRainsProcessNum isRainsProcessNum, ");
		sql.append("ld.type legendType,p.productName productName,pd.type productType,cdp.requestPath requestPath,cdp.pictureRequestPath pictureRequestPath, " +
				"asd.type isAreaChoice, ssd.type siteType from climate_disaster_product cdp  ");
		sql.append("left join product p on p.productId = cdp.id " +
				"left join sys_dict hd on hd.id = cdp.horizontalAxisUnit " +
				"left join sys_dict ld on ld.id = cdp.legendType  " +
				"left join sys_dict asd on asd.id = cdp.isAreaChoice " +
				"left join sys_dict ssd on ssd.id = cdp.siteType " +
				"left join sys_dict pd on pd.id = p.productType ");
		sql.append("where cdp.isDelete = '0' and cdp.publishFlag = '1' and cdp.id=?");


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值