Blog reboot.

Seeing as this Blog has no readers, I’m not entirely sure who this post is aimed at. That said, for some reason I feel compelled to make this post anyway – in much the same way I imagine most people do when they create a new blog themselves. So here it is!

New design, check. Rambling and incoherency (kinda) first post, check. Motivation to actually use this Blog properly, check.

Now, just for the reason this blog may as well have some content. I was asked earlier today how best to select rows from a database where a particular number existed in a comma separated list inside one of the fields. The issue being that performing a straight

SELECT * FROM 'someTable'
WHERE  'someRow'  LIKE '%7%'

would end up pulling in any records containing 77/27/73 along with the actual rows required (in which the number 7 itself actually existed). My off the top of my head solution was to include the comma’s in the query, which resulted in somthing along the lines of

SELECT * from 'someTable'
WHERE   'someRow' LIKE '%,7,%'
OR      'someRow' LIKE '7,%'
OR      'someRow' LIKE '%,7'

which would theoretically be able to get the 7 in any place while still excluding any numbers such as 27, 77 or 72.

If anyone knows of a more elegant solution to the problem it would be interesting to hear. Also any feedback/criticism on the new Blog layout would also be great.

By Carl on June 15th, 2011 in General