I have seen the light…

Just occasionally something comes along that makes this world a better place. The SQL concat function is one such thing. For years I have been floundering in multiple-query hell, but no more! Thanks to the great M@ I just discovered one more of the delights of SQL.

You see, for ages now I’ve been doing the old:

select something from aTable where this=that;

Then writing the resulting “something” string value into a variable, such as $something, and then doing:

$something = $something + "something else!"

update aTable set something = '$something' where this=that

Do you see my foolishness? Do you? Well, *cue all-knowing chuckle* the concat function does away with all that nonsense, replacing it with:

update aTable set something = concat(something,'something else!')

My joy is complete and my cup runneth over. You may be thinking “Did he, a self-proclaimed geek, not know that?”, and you’re right – I didn’t. But I do now, and boy will I be using it to the full. All hail the power of new and nifty functions!