Basic string searching in MySQL table columns

Last weekend, I ended up doing a spot of file structure reorganisation on the web server for www.johnhennessy.co.uk and needed to correct some file pointers in entries on my outdoors blog. Rather than grabbing a plugin from somewhere, I decided to edit the posts table directly. First, I needed to select the affected observations and this is where I needed to pick out the affected rows and edit them in MySQL Query Browser. To do that, I needed basic string searching so I opened up my MySQL eBook from Apress and constructed something like the following:

select * from posts_table where post_text like ‘%some_text%’;

The % wildcard characters are needed to pick out a search string in any part of a piece of text. There may be more sophisticated method but this did what I needed in a quick and dirty manner without further ado. Well, it was what I needed.

1 comment

Pingback: Links 30/4/2010: *Ubuntu 10.04 Release | Techrights

Leave a Reply