From the course: MySQL Essential Training (2019)

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

String concatenation

String concatenation

- [Instructor] MySQL does not support the SQL standard string concatenation operator, instead it uses a function. So the standard string concatenation operator in SQL would look something like this, and now, if I execute this in MySQL, you notice that I get a zero, and that's because the string concatenation operator is already used in MySQL as the logical or operator, so we're just saying string or string or string, and MySQL doesn't quite know what to do with that, so it returns a logical false. Instead, MySQL uses the concat function, like this, and instead of these double bars, you simply use commas. Now when I execute this, you see that the result is this and that, as we would expect. The concat function takes any number of arguments. I can say love is all you need, at least according to John Lennon. Now when I execute this, we get love is all you need or you can give it just two arguments, which is very, very common, and when I run that, we get one, two, all run together. Any…

Contents