0

你好,正如我昨天讨论的从多个表中检索数据到

多个查询,但我得到了很多关于将表连接到一个查询中的好建议。

实际上在这里我将多个表加入到一个查询中,但我想检索数据

仅从两个表中,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";
4

2 回答 2

1

从行中删除 ' , '

pds.PDName,

并且最好尝试加入任何两个表,例如

FROM properties
JOIN provinces ON provinces.PropertyId = properties.provinceId
于 2013-06-04T04:57:20.973 回答
0

您已将,From 子句之前的 the 删除。在这儿

pds.PDName

喜欢它:

districts.DistrictName,
pds.PDName

FROM properties, provinces, districts, pds, propertyimages
于 2013-06-04T04:58:54.950 回答