无法找到解决方案: - 之前找到了别名。 (在" req_id"在909位置附近)

时间:2016-03-11 13:42:04

标签: mysql sql

这是查询,我无法找到此解决方案之前找到了一个别名 near" req_id" 。为什么会出现这种错误?请查看它。

select property.property_type,
property.agent_id,
agents_profile.user_photo, 
agents_profile.phone_no, 
agents_profile.first_name,   
agents_profile.family_name,
agents_profile.mob_verify_flag,
property.location,
property.longitude,
property.latitude, 
property.images,    
property.floor_plan_image,
property.epc_image, 
property.available_start_date,
property.available_end_date, 
property.monthly_rent, 
property.deposit, 
property.bedrooms,
property.bathrooms,
property.furnished_type,
property.is_secure_access, 
property.is_above_street_level,
property.is_parking,
property.is_parking_covered, 
property.total_parking, 
property.is_parking_secure, 
property.is_garden,
property.accept_social_housing_tenant,
property.flag,
property.isWifiAvailable,
property.isPetsPresent,
property.isSmoking,
property.isStudent 
     (SELECT id 
      FROM `request_property` 
      WHERE tenant_id=0 AND agent_id=property.agent_id AND property_id=294
      LIMIT 1) as req_id
FROM property
INNER JOIN agents_profile ON  property.agent_id=agents_profile.agent_id
WHERE property.id=294
LIMIT 0, 25`

2 个答案:

答案 0 :(得分:1)

没有逗号将子查询字段定义与字段列表分开:

select property.property_type,
...
property.isStudent,  <---this comma was missing 
(SELECT id 
      FROM `request_property` 
      WHERE tenant_id=0 AND agent_id=property.agent_id AND property_id=294
LIMIT 1) as req_id
FROM property
INNER JOIN agents_profile ON  property.agent_id=agents_profile.agent_id
WHERE property.id=294
LIMIT 0, 25`

答案 1 :(得分:1)

您在isStudent之后错过了逗号:

// more stuff above
property.isSmoking,
property.isStudent, -- HERE 
     (SELECT id 
      FROM `request_property` 
      WHERE tenant_id=0 AND agent_id=property.agent_id AND property_id=294
      LIMIT 1) as req_id
FROM property