From the course: MySQL Essential Training

Unlock this course with a free trial

Join today to access over 23,700 courses taught by industry experts.

String concatenation

String concatenation - MySQL Tutorial

From the course: MySQL Essential Training

String concatenation

- [Bill] Hi, I'm Bill Wyman. MySQL does not support the standard string concatenation operator. Instead, it uses a function for this purpose. The standard SQL string concatenation operator is the double vertical bar. So it looks like this. If I say select this, and the double bar for concatenation, and a double bar for concatenation that, and you notice I put in spaces here and here. So we get spaces, but this doesn't actually work as expected. If I execute this, it gives us a zero, and that's because these double bar operator is already taken in MySQL for the logical or function. And you remember that when operated on biological operators, strings are converted to numbers and in this case, they're all converted to zero. 'cause there aren't any numbers in these strings, and zero or zero is zero. So instead, MySQL uses a function for this called concat, which is short for concatenation. And I can't use these double bars, so I have to change them to commas. And now when I execute this…

Contents