Home rolled gridview search results shows rows that are supposed to be ignored Note: I tried posting this on Stack Overflow but didn't get any good bites.  I'm still researching this but wanted to see if any db czars can assist here.

I'm in the process of trying to troubleshoot some SQL 2012 code in an ASP/C# gridview search that I rolled myself.  I have a search box that searches on specific fields but the twist here is that I only want results after a certain row.

In this database I have a sequence command that autogenerates a number in a column called 'record_number' for every entry in this table and only want results after record #500.  The entries are created manually via a different page.

Right now my search code is as follows:

"SelectCommand="SELECT [record_number], [column_a], [column_b], [column_c], 
    [column_d], [column_e], [column_f], [column_g], [column_h], 
    [column_i], [column_j] 
  FROM [schema].[table_name] WHERE record_number &gt;= 500 
  AND ([column_a] LIKE '%' + @column_a + '%') 
   OR ([column_c] LIKE '%' + @column_c + '%') 
   OR ([column_e] LIKE '%' + @column_e + '%')
   OR ([column_g] LIKE '%' + @column_g + '%')
   OR ([column_h] LIKE '%' + @column_h + '%')
   OR ([column_j] LIKE '%' + @column_j + '%')"


I can post my SelectParameters if needed or anything else.  The challenge I'm facing is when I run a search for just the letter 'c' leveraging this code, the results that post have a record_number less AND greater than than 500. At this point I'm spinning my wheels as I'm not seeing where the problem lies.

If more information is needed by the masses, please let me know.

EDIT

Forgot this part - I've tried moving around the commands and consolidating the commands but no go.
@Mark is absolutely right. AND has higher precedence, so what your query is really saying is:

WHERE record_number &gt;= 500 AND (column_a LIKE '%something%')

OR 

column_c LIKE '%something else%'

OR

column_e LIKE ...


What you want it to say is:

WHERE record_number &gt;= 500

AND

column_a LIKE '%something%' OR column_c LIKE '%something else%' OR ...


The way you do this is through parentheses. So:

WHERE record_number &gt;= 500
AND
(column_a LIKE '%something%' OR column_c LIKE '%something else%' OR ... )


However I also agree with Mark's idea that this is wrong on many levels. Why have you hard-coded the query to not care about the first 499 rows? What happens if the user doesn't enter a parameter for one of the columns? Do you expect this to perform well when your table gets large and you are essentially forcing scans to find all of the matching rows?