Constructing a good search query using system.data.oracleclient

后端 未结 2 1481
再見小時候
再見小時候 2021-01-07 03:53

I am constructing a search function in a class to be used by several of our asp pages. The idea is simple, take a search term from the user and query the database for the i

2条回答
  •  忘掉有多难
    2021-01-07 04:19

    Instead of doing the concatenation in your VB code, do the concatenation in the SQL statement. Then what you're trying to do should work. Here's some SQL illustrating what I'm talking about:

    select ID_ELEMENT, ELEMENT_NAME 
    from table_of_elements 
    where upper(ELEMENT_NAME) like ('%' || upper(:searchterm) || '%')
    

    BTW, you might end up with more efficient queries if you switch the collation on ELEMENT_NAME to case-insensitive and then remove the calls to upper().

提交回复
热议问题