SELECT Distinct ListingId,FieldId,FieldValue
FROM [Chant-GreyPar].[dbo].[gp_listing_field]
where (FieldId = 54) and (FieldId = 69)
order by ListingId asc
好傢伙選擇ID我有表從柱= 1和第2列MSSQL 2012
ListingId FieldId FieldValue
238878 54 Paupackan Lake
238878 69 N
238879 54 None
238879 69 N
238880 54 Westcolang Lake
238881 54 None
238882 54 None
,我需要選擇的ID了FieldId 54和69 ...需要幫助烏拉圭回合。
UPDATE:
select distinct l.Id,[SquareFeet],[HouseNumber],[StreetAddress],[PropertyTypeId],[Bedrooms],[Bathrooms],[ListingPrice],
(select top 1 PhotoUrl from [Chant-GreyPar].dbo.gp_listing_photo where gp_listing_photo.ListingId = f.ListingId) AS PhotoUrl,
(Select AreaName1 from [Chant-GreyPar].dbo.gp_location where gp_location.Id = l.LocationId) AS AreaName1,
(Select AreaStateCode from [Chant-GreyPar].dbo.gp_location where gp_location.Id = l.LocationId) AS AreaStateCode
from [Chant-GreyPar].dbo.gp_listing l inner join [Chant-GreyPar].[dbo].[gp_listing_field] f
on f.ListingId = l.Id left join [Chant-GreyPar].dbo.gp_vw_DecimalListingField s on s.ListingId = l.Id
where (l.DisplayListing='1' and f.FieldId='69' and f.FieldValue='Y') and (l.DisplayListing='1' and f.FieldId='15' and f.FieldValue='Window Unit AC' or f.FieldValue='Wall Unit AC' or f.FieldValue='Window Unit AC' or f.FieldValue='Central AC')
and ListingPrice >= 0 and ListingPrice <= 99999999999 and Bedrooms >= 0 and Bathrooms >= 0
and SquareFeet >= 0 and (FieldValueDecimal >= 0 or FieldValueDecimal is null)
order by ListingPrice desc
如何整合在這裏它。 Thnks。
FieldId不可能是59 _和_ 64.你應該使用OR來代替(或者使用IN()條件) –