• GAWDS
  • Nik Makris is a Learning Tree .NET Enterprise Application Development Certified Professional
    .NET Enterprise Application Development
    Certified Professional
    Learning Tree International
  • Nik Makris is certified under the CCNA® program
    Nik Makris is certified under the CCNA® program
  • Nik Makris is Google Analytics Qualified
    Nik Makris has obtained the Google Analytics Individual Qualification
Blog

MySQL vs TSQL Concatenation CONCAT()

5. January 2005 09:53

Following on from an entry posted last year concerning converting SQL queries from Microsoft TSQL to MySQL I've come across another function which is treated somewhat differently in MySQL than TSQL.

The following SQL code adds the .jpeg file extension onto the end of the image names from tblImages.

TSQL Concatenation

SELECT ImageName+'.jpeg' FROM tblImages

The above SQL syntax is used on Microsoft SQL Server, Microsoft Access and Sybase

MySQL Concatenation

SELECT CONCAT(ImageName,'.jpeg') FROM tblImages

Oracle Concatenation

SELECT ImageName || '.jpeg' FROM tblImages

The Oracle syntax is the syntax recommended by the SQL specification. It uses 2 pipes || instead of a plus + sign. This avoids the problems of trying to concatenate integer fields which might otherwise result in an unwanted addition.

Previous entry: T-SQL TO MYSQL CONVERSIONS

Tags: , ,

Filed under: Databases

Comments are closed