你好,正如我昨天所讨论的那样,从多个表中检索数据到
多个查询,但我有很多建议将表连接成一个查询。
实际上在这里我将多个表连接成一个查询,但我想检索数据
仅来自两个表T1是属性,T2是相关属性的图像。
我做了但它给出了一个我无法找到它的错误。
Error Massage : #1064 - You have an error in your SQL syntax;
check the manual that
corresponds to your MySQL server version for the right syntax to use near 'FROM
properties, provinces, districts, pds, propertyimages WHERE Provinces.'
at line 22
Here is the Query:
"SELECT
properties.PropertyID,
properties.PropertyName,
properties.PropertyType,
properties.PropertyDealType,
properties.PropertyRegion,
properties.PrepostedPrice,
properties.PricePerArea,
properties.DealStatus,
properties.MoreinfoDealGeneralInformation,
properties.MoreInfoPropertyGeneralInformation,
properties.CurrencyType,
propertyimages.PropertyID,
propertyimages.ImageName,
propertyimages.ImagePath,
Provinces.ProvinceName,
districts.DistrictName,
pds.PDName,
FROM properties, provinces, districts, pds, propertyimages
WHERE Provinces.ProvinceID=Properties.ProvinceID
AND districts.DistrictID=Properties.DistrictID
AND pds.PDID=properties.PDID
AND properties.PropertyID=propertyimages.PropertyID
AND ProvinceName= 'Kabul'
AND DistrictName='KabulCity'
AND PropertyDealType='For Rent'
ORDER BY properties.PropertyID";
答案 0 :(得分:1)
从
行中删除“,”pds.PDName,
最好尝试加入任何两个表,如
FROM properties
JOIN provinces ON provinces.PropertyId = properties.provinceId
答案 1 :(得分:0)
在From子句删除之前,您已离开,
。
在这里
pds.PDName
喜欢它:
districts.DistrictName,
pds.PDName
FROM properties, provinces, districts, pds, propertyimages