Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to filter on multiple fields in SELECT?

Author  Topic 

Maverick_
Posting Yak Master

107 Posts

Posted - 2013-03-11 : 07:57:02
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
Posting Yak Master

101 Posts

Posted - 2013-03-11 : 08:49:39
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
   

- Advertisement -