membersound
membersound

Reputation: 86915

How to set collation of columns in mysql view?

How can I explicit set the collation of a mysql-view or its columns? I want to explicit set the collation to collacation=utf8_general_ci for all text/char/varchar columns.

Pseudo-mysql:

CREATE VIEW my_view AS
    SELECT 
        CONCAT(my_table.some + my_table.more),
        some_field, 
        ...
    FROM
        my_table;

Upvotes: 3

Views: 2215

Answers (1)

Barmar
Barmar

Reputation: 782498

Use the CONVERT(value USING name) function to specify the character set and collation of an expression.

CREATE VIEW my_view AS
SELECT CONVERT(something USING utf8)
...

Upvotes: 4

Related Questions