Tutorial by Examples

The % wildcard appended to the beginning or end (or both) of a string will allow 0 or more of any character before the beginning or after the end of the pattern to match. Using '%' in the middle will allow 0 or more characters between the two parts of the pattern to match. We are going to use this...
To broaden the selections of a structured query language (SQL-SELECT) statement, wildcard characters, the percent sign (%) and the underscore (_), can be used. The _ (underscore) character can be used as a wildcard for any single character in a pattern match. Find all employees whose Fname start w...
Match any single character within the specified range (e.g.: [a-f]) or set (e.g.: [abcdef]). This range pattern would match "gary" but not "mary": SELECT * FROM Employees WHERE FName LIKE '[a-g]ary' This set pattern would match "mary" but not "gary": SEL...
Match any: Must match at least one string. In this example the product type must be either 'electronics', 'books', or 'video'. SELECT * FROM purchase_table WHERE product_type LIKE ANY ('electronics', 'books', 'video'); Match all (must meet all requirements). In this example both 'united...
Following statement matches all records having FName that starts with a letter from A to F from Employees Table. SELECT * FROM Employees WHERE FName LIKE '[A-F]%'
If you implement a text-search as LIKE-query, you usually do it like this: SELECT * FROM T_Whatever WHERE SomeField LIKE CONCAT('%', @in_SearchText, '%') However, (apart from the fact that you shouldn't necessarely use LIKE when you can use fulltext-search) this creates a problem when someb...
wildcard characters are used with the SQL LIKE operator. SQL wildcards are used to search for data within a table. Wildcards in SQL are:%, _, [charlist], [^charlist] % - A substitute for zero or more characters Eg: //selects all customers with a City starting with "Lo" SEL...

Page 1 of 1