Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6631537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:33:34+00:00 2026-05-25T22:33:34+00:00

I have table called Property and the data is like pid city state state_abb

  • 0

I have table called Property and the data is like

   pid     city           state          state_abb      address1   address2
    x1     NewCity        NHANy              NH          xxxx      gfg
    x2     Gloucester     Manchestar         MA          newAde    xxxx
    x3     OtherC         NewYork            NY          yyyy

I want a query with search keyword to display order like (state or state_abb), city, address1, adress2

For ex:

If I search keyword with New The result output should

    pid   city         state        state_abb   address1    address2
     x3   OtherC       NewYork         NY       yyyy 
     x1   NewCity      NHANy           NH       xxxx        gfg
     x2   Gloucester   Manchester      MA       newAde      xxxx

I don’t want unmatched rows.I want display only matched rows.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:33:35+00:00Added an answer on May 25, 2026 at 10:33 pm

    It think the question is how to order the results, not how to perform the search. Try this as your ORDER BY clause

    order by
     case when charindex('NEW',state) >0 then 1000 else 0 end desc,
     case when charindex('NEW',city) >0 then 100 else 0 end desc, 
     case when charindex('NEW',address) >0 then 10 else 0 end desc
    

    Where clause to only get matching rows

     select * from Property where
            city     like '%New%' or
            state    like '%New%' or
            address1 like '%New%' or
            address2 like '%New%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Data Class called MyTable, and the source property is TABLE (table
I have a table which contains house details called property. I am creating a
I have table called stats . In am inserting yes or no in the
I have a table called OffDays, where weekends and holiday dates are kept. I
I have a Table called Product and I have the Table StorageHistory . Now,
I have a table called ApprovalTasks... Approvals has a status column I also have
I have a table called BlogPost which has a 1-to-many relationship with the Comment
i have a table called category in which i have main category ids and
I have a table called Orderrow. Orderrow has a a compound primary key (CPK)
We have a table called table1 ... (c1 int indentity,c2 datetime not null,c3 varchar(50)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.