SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to filter on multiple fields in SELECT?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Maverick_
Posting Yak Master

107 Posts

Posted - 03/11/2013 :  07:57:02  Show Profile  Reply with Quote
Hi there,

I am trying to insert a field in my SELECT statement which allows a user to search for something which could be contained in multiple fields.

For example, if a user was to search for enquiries on High Road in the 'Search' field, the 'Search' field should contain site_name, enquiry_location, feature_location, and Feature_ID fields.

The above fields are all CHAR fields. Is there a way to combine all the fields and make it available for a user to search on in a SELECT statement?

If you have suggestions please share

Robowski
Yak Posting Veteran

99 Posts

Posted - 03/11/2013 :  08:49:39  Show Profile  Reply with Quote
Are you passing the value in as a parameter?

Not 100% I fully understand what your asking, but can you use an OR in the where clause?
SELECT
*
FROM
Table
WHERE
(site_name = @Param OR enquiry_location = @Param OR feature_location = @Param OR Feature_ID fields = @Param)
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000