aebstract Posted March 19, 2008 Share Posted March 19, 2008 I suck at regular expressions.. I know some of the commands and whatnot, and almost understand the syntax of it. I'm wanting to retrieve information from a database, basically a simple search engine. It will search one column for anything that includes what was searched for. Example being: If you search for 20. Let's say there are 3 parts with 20 in them, BPRSW20 SWO20JAL 204589 I want to be able to retrieve the rows with these parts in them. Any row that has the searched for criteria, anywhere in the part number. I don't want anyone to write this for me but help me out with how I would go about doing it please. Link to comment https://forums.phpfreaks.com/topic/96916-how-to-regular-expression/ Share on other sites More sharing options...
effigy Posted March 19, 2008 Share Posted March 19, 2008 If your searches remain simple, you can use wildcards: SELECT * FROM table WHERE field LIKE '%20%' Link to comment https://forums.phpfreaks.com/topic/96916-how-to-regular-expression/#findComment-495928 Share on other sites More sharing options...
aebstract Posted March 19, 2008 Author Share Posted March 19, 2008 What do the % signs do? If my search was for say "RKK-940" would it be like %RKK-940% and find that exact matching in my part numbers? So it would find part SPRKK-940006 ? Link to comment https://forums.phpfreaks.com/topic/96916-how-to-regular-expression/#findComment-495943 Share on other sites More sharing options...
effigy Posted March 19, 2008 Share Posted March 19, 2008 Per the docs: With LIKE you can use the following two wildcard characters in the pattern: % -- Matches any number of characters, even zero characters _ -- Matches exactly one character So it would find part SPRKK-940006 ? Correct. Link to comment https://forums.phpfreaks.com/topic/96916-how-to-regular-expression/#findComment-495953 Share on other sites More sharing options...
aebstract Posted March 19, 2008 Author Share Posted March 19, 2008 Works just like what I was looking for, thank you Link to comment https://forums.phpfreaks.com/topic/96916-how-to-regular-expression/#findComment-496037 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.