本文介绍了连接3个表throws关键字'WHERE'错误附近的语法不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我的查询是加入3个表,但它抛出错误查询是 选择 distinct p.projectid,p.projectname,p.location,p.bedrooms,p.city,p。概述,p.price,s.builduparea,s.bedrooms,s.bathrooms,s.propertyonfloor,s.price,s.units,c.speci,c.amenities from plisting p join indi s JOIN Sheet1 $ c p.projectid = s.projectid AND s.projectid = c.projectid WHERE s.projectid = ' PL2023002' order by p.projectname,s.projectname 但它会抛出错误 消息156,等级15,状态1,第4行 关键字''WHERE''附近的语法不正确。 请帮我解决这个问题解决方案 c p.projectid = s.projectid AND s.projectid = c.projectid WHERE s.projectid = ' PL2023002' 订单 p.projectname,s.projectname 但它会抛出错误 Msg 156,Level 15,State 1,Line 4 关键字''WHERE''附近的语法不正确。 请帮我解决这个 看起来你错过了前两个表的加入列( ON 子句) 为连接添加适当的列,如下所示: 选择 distinct p.projectid, p。 projectname, p.location, p.bedrooms, p.city, p.overview, p.price, s.builduparea, s.bedrooms, s.bathrooms, s.propertyonfloor, s.price, s.units, c.speci, c.amenities, s.projectname from plisting p join indi s on p.projectid = s.projectid JOIN Sheet1 c on s.projectid = c.projectid WHERE s.projectid = ' PL2023002' order by p.projectname, s。 projectname 为了让 DISTINCT 工作,添加 s.ProjectName 到选择列表(添加为最后一列) my query is to join 3 tables but it throws error query is select distinct p.projectid,p.projectname,p.location,p.bedrooms,p.city,p.overview,p.price,s.builduparea,s.bedrooms,s.bathrooms,s.propertyonfloor,s.price,s.units,c.speci,c.amenitiesfrom plisting pjoin indi s JOIN Sheet1$ c on p.projectid=s.projectid AND s.projectid = c.projectidWHERE s.projectid='PL2023002'order by p.projectname,s.projectnamebut it throws errorMsg 156, Level 15, State 1, Line 4Incorrect syntax near the keyword ''WHERE''.pls help me solve this 解决方案 c on p.projectid=s.projectid AND s.projectid = c.projectidWHERE s.projectid='PL2023002'order by p.projectname,s.projectnamebut it throws errorMsg 156, Level 15, State 1, Line 4Incorrect syntax near the keyword ''WHERE''.pls help me solve thisLooks like you have missed the joining columns for the first two tables (ON clause)Add proper columns to the join so something like the following:select distinct p.projectid, p.projectname, p.location, p.bedrooms, p.city, p.overview, p.price, s.builduparea, s.bedrooms, s.bathrooms, s.propertyonfloor, s.price, s.units, c.speci, c.amenities, s.projectnamefrom plisting p join indi s on p.projectid=s.projectid JOIN Sheet1c on s.projectid = c.projectidWHERE s.projectid='PL2023002'order by p.projectname, s.projectnameAlso in order for the DISTINCT to work, add s.ProjectName to the select list (added as the last column) 这篇关于连接3个表throws关键字'WHERE'错误附近的语法不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-15 21:35