For very simple string comparisons, use =, as in _wbs='Fish'_
For more complex string comparisions with simple wildcards, use LIKE as in _wbs LIKE "%fish%"
_For most complex comparisions, use a regular expression, as in _wbs REGEXP ".\d"_
In the REGEXP example I listed above, the pattern will match all strings which contain one character (.) followed by one digit (\d). If you want to only match strings which /start/ with one chracter followed by one digit, for example, you would say "^.\d".
. represents any character
\d represents only characters in the digits class (0-9)
^ means at the start of the string (if it's at the start of the regexp, otherwise it can mean "not")
Regular expressions are amazing things if used properly. http://www.mysql.com/doc/en/Pattern_matching.html
Note that in MySQL, the wildcard characters are _ and %, where _ represents a single character and % represents any number of characters, unlike Access, where if I remember, # means one char and * means any number of characters (?)
Good luck!
For Jacque Scott wrote:
I am converting over to mySQL from Access 2.0 and I am having a little trouble with a query. Here it is:
SELECT Max(WBS) AS LastOfWBS FROM Projects Where((WBS)) Like """ & txtEntryData(0).Text & "#%"";
I am trying to get the last WBS ID starting with a particular letter the user will type in the textbox. My criteria is that it has to start with a letter and the next character is a number. There can be letters or more numbers to the right of the first number. For example: A01C or B001, but not AB01. In Access we could use the following query:
SELECT DISTINCT Max([Projects].[WBS]) AS LastOfWBS FROM Projects where (Projects.WBS) Like """ & txtEntryData(0).Text &
"#*"";
How can I insure when using mySQL that the second character is a number?