String concatenation in MySQL

MySQL is different from most DBMSs’ use of + or || for concatenation. It uses the CONCAT function: SELECT CONCAT(first_name, ‘ ‘, last_name) AS Name FROM test.student There’s also the CONCAT_WS (Concatenate With Separator) function, which is a special form of CONCAT(): SELECT CONCAT_WS(‘ ‘, first_name, last_name) from test.student That said, if you want to … Read more

Can I concatenate multiple MySQL rows into one field?

You can use GROUP_CONCAT: SELECT person_id, GROUP_CONCAT(hobbies SEPARATOR ‘, ‘) FROM peoples_hobbies GROUP BY person_id; As Ludwig stated in his comment, you can add the DISTINCT operator to avoid duplicates: SELECT person_id, GROUP_CONCAT(DISTINCT hobbies SEPARATOR ‘, ‘) FROM peoples_hobbies GROUP BY person_id; As Jan stated in their comment, you can also sort the values before … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)