WOW: Tips and Tricks
.: Adding a Wildcard Search to an Operation Within WOW you can create searches or prompts in many different ways. You can search with operators such as like, =, <, > and helpers like a date picker. There are times when you would like to search through a column for certain text. It may be a search for keywords or documentation. The LIKE condition is used to specify a search for a pattern in a column. Here is an example of a basic SQL operation with a search using the like operator.
For example,
SELECT * FROM samples.notes WHERE notes LIKE ? If a user enters “Jon” then all records which have a notes field that starts with “Jon” will be returned. WOW does this by substituting the “Jon” with “Jon%” and then executing the SQL statement. A "%" sign can be used to define wildcards (missing letters in the pattern) both before and after the pattern. NOTE: Whenever using LIKE operator, WOW will always add “%” after the search parameter. There are cases where you want to search through an entire text field or area and return the pattern matches. You still would like the user to enter the search string but want to search for that pattern throughout the entire column and even parts of words within entire column. To do this we need to add the wildcard before our search parameter by putting together “%” and “?” (Use CONCAT function or similar SQL function). SELECT * FROM samples.notes WHERE notes LIKE CONCAT (‘%’ , ?) In this case if a user enters “Jon”, WOW will replace it with “%Jon%” and return any record that has “Jon” anywhere within the column. For More Information on SQL and the LIKE operator check out: http://www.w3schools.com/sql/sql_where.asp |