Data Diving Continued – mySQL Issues

Another trend I see in referers is people goggling for info about OSS databases, of which I often write/rant about.

One of the search engine queries I see most often is looking for the concat function in Postgres.

Which is another reason mySQL is not a good database.

Following are the methods of concatinating strings (strings “foo” and “bar”) in three common databases:

MYSQL:

select concat(‘foo’,’bar’) from table

MS SQL SERVER

select ‘foo’ + ‘bar’ from table

POSTGRES

select ‘foo’ || ‘bar’ from table

(Result for all three will be ‘foobar’)

I’m not certain, but I think Oracle concatenates the same way as Postgres.

Notice that mySQL has a function (the concat() function) rather than an operator (|| or +). While you can argue the reletive merits of each – both for speed and for perceived friendliness – you have to admit that the mySQL implementation is different enough from other databases and languages to make it damn near impossible to figure out without a manual.

I remember when I first was working with mySQL and needed to concatinate. No other database language – or programming languages – uses a function for this. So I attempted to add these two strings together with all sorts of operators: +, ||, &, &&, . (like Perl and PHP) and so on.

Then I RTFM, and ran across this wacky function.

Oh well, it works, but still…just not professional feeling, as it’s so different from all other scripting languages I use. Just odd and unsettling.

And if people are hitting Google trying to figure out the Postgres concat function, it means that they’ve learned SQL with mySQL, which is as far from ANSI-compliant as any common database.

And so – in the folks’ minds, this type of function is a standard SQL type function.

But it’s not…

Again, not a deal-breaker, but is odd enough to mess people up in the beginning (either learning mySQL after using more advanced databases, or moving to an advanced database from mySQL) and continue to annoy long after that.