Select Id from column = 1 and column 2 MsSql 2012 -


  select separate listing ID, field id, field value [chant-grape] [Dbo] [GP_Listening_field] where (field ID = 54) and (field ID = 69) listing by orderIICAC   

Hello friends I have a table

  ListingId FieldID FieldValue 238878 54 Paupkin Lake 238878 69 N 238879 54 None 238879 69 N 238880 54 Vestkong Lake 238881 54 None None 238882 54 None I need to choose the field ID 54 and 69 ID got. .. ur help is needed.  

Update:

  Typical LID, [SquareFit], [Hausnmember], [StreetAdder], [Property Type ID], [Bedroom], [Bathroom], [ Listprint], select [snap-grayPar] .dbo.gp_location where gp_location.id = l.LocationId] [snap-grayPar] .dbo.gp_listing_photo where gp_listing_photo.ListingId = f.ListingId) as PhotoUrl, (from Selection AreaName1 Top 1 PhotoUrl as AreaName1, ([Chan-Grapear]. Select area area code from dbo.gp_location where gp_location.id = l.LocationId) Aristotelcode fr om [jap-greypar] .dbo.gp_listing L evening in the evening Having [jap-grayPar]. [Dbo]. [Gp_listing_field] f f.ListingId = l.Id is left to join [jap-greypar] .dbo.gp_vw_DecimalListingField on the list .IDID = LID where (L. Display = '1' and F. Felidy = '69 'and F. Field Value =' Y ') and (L. DisplayListening =' 1 'and F. FieldID =' 15 'and' F Field Value ' Window unit AC 'or' F 'field value =' Wall unit AC 'or' F 'field value =' Window unit AC 'or F. Field value =' Central AC ') And Listprint & gt; = 0 more listingsPrint & lt; = 99999999999 and bedroom> = 0 and bathroom = gt; = 0 and sqft & gt; = 0 more (FieldWolm> gt; = 0 or FieldWheel is empty) LiftProp Dis << Code / code>  

How the sequence integrates here. Thnks.

OK, if you are trying to do what I think you can do Trying, use: ...

  Select DISTINCT ListingId, from FieldId, [JAP-GreyPar] [dbo] FieldValue [gp_listing_field] Where in the ListingId (Select [JAP-GreyPar] ListingId [dbo] [gp_listing_field ] WHERE FieldId IN (54, 69) Listing Howiving Count (Listings) by Group = 2) Listing ID ASC   

This uses a sub-query WHERE clause), all of the ListingId To get the list containing 2 records are searching the WHERE clause 2 values ​​in the sub-query filter - 54 and 69 - so it is only you Nothing will be given to the records which are both 54 and 69. The main query then uses that list to get the values ​​just for those lines

Your update is a bit complicated without the database in front of me. All your sub-queries are used in place of the first part of your WHERE section where you should search for fieldID values There are no guarantees that my syntax is correct:

  USE [Chanat-Grapear] - This eliminates the need to repeat the query, choose Go Choose Inter IID , Squarefight, Hausnmember, S StreetEdder, PhotoTypeId, Bedroom, Bathroom, ListPrice, (Select Top 1 PhotoRural DBA.gp_listing_photo WHERE gp_listing_photo.ListingId = f.ListingId) as PhotoUrl (SELECT AreaName1 to dbo.gp_location WHERE gp_location.Id = l.LocationId) ASName1 , (Include SELECT dbo.gp_location to AreaStateCode where gp_location.Id = l.LocationId) dbo.gp_listing in the form of AreaStateCode L.Id left on f.ListingId = l.Id join dbo.gp_listing_field f dbo.gp_vw_DecimalListingField s on s .ListingId = l.Id Where in ListingId (Selection ListId from dbo.gp_listing_field where (l.DisplayListing = '1' and f.FieldId = '69 'and f.FieldValue =' Y ') or (l.DisplayListing =' 1 'And f.FieldId =' 15 'and' A ' Listed Living Count (listing ID) = 2) and 0 and + 99999999999 and bedroom & gt; field value in ('window unit AC', 'wall unit AC', 'window unit AC', 'central AC')). Between ListingPrice; = 0 and bathroom & gt; = 0 and SquareFeet & gt; = 0 and (FieldValueDecimal> gt; = 0 or FieldValueDecimal IS NULL) By listingPrice DESC   

By the way, you have changed the second field ID value from 54 to 15. Not sure that it was deliberately.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -