COLLATE sort operator allows you ro specify a collation in your expression. : Collate « I18N « SQL / MySQL






COLLATE sort operator allows you ro specify a collation in your expression.

   
mysql>
mysql> CREATE TABLE ProductColors
    -> (
    ->     ProdID SMALLINT NOT NULL PRIMARY KEY,
    ->     ProdColor VARCHAR(15) NOT NULL
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql>
mysql>
mysql> INSERT INTO ProductColors VALUES
    -> (101, 'Red'),
    -> (102, 'red'),
    -> (103, 'RED'),
    -> (104, 'REd'),
    -> (105, 'reD'),
    -> (106, 'Blue'),
    -> (107, 'blue'),
    -> (108, 'BLUE'),
    -> (109, 'BLue'),
    -> (110, 'blUE');
Query OK, 10 rows affected (0.00 sec)
Records: 10  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> SELECT * FROM ProductColors
    -> WHERE ProdColor COLLATE latin1_german2_ci = 'red';
+--------+-----------+
| ProdID | ProdColor |
+--------+-----------+
|    101 | Red       |
|    102 | red       |
|    103 | RED       |
|    104 | REd       |
|    105 | reD       |
+--------+-----------+
5 rows in set (0.00 sec)

mysql>
mysql>
mysql> drop table ProductColors;
Query OK, 0 rows affected (0.00 sec)

   
    
    
  








Related examples in the same category

1.Set COLLATE=latin1_german1_ci
2.ORDER BY and COLLATE latin1_german2_ci
3.ALTER TABLE employee MODIFY employee VARCHAR(60) CHARACTER SET latin1 COLLATE latin1_german2_ci;
4.ORDER BY CONVERT(firstname USING utf8) COLLATE utf8_polish_ci;
5.SELECT firstname FROM employee ORDER BY firstname COLLATE latin1_general_ci
6.SELECT firstname FROM employee ORDER BY firstname COLLATE latin1_german1_ci
7.SELECT firstname FROM employee ORDER BY firstname COLLATE latin1_swedish_ci
8.SELECT firstname FROM employee ORDER BY firstname COLLATE utf8_general_ci
9.Create database with character set and collate
10.Change the character set name and collate name for database
11.Change collate for database
12.COLLATE utf8_romanian_ci for column definition
13.Set the character set and collate for a table
14.COLLATE 'latin1_danish_ci'
15.ORDER BY a column COLLATE latin1_swedish_ci
16.Cast COLLATE
17.Order by collate
18.Alter table to change the collate setting
19.Check the collation name
20.Get collation
21.ERROR 1267 (HY000): Illegal mix of collations (latin1_general_ci,IMPLICIT) and (latin1_danish_ci,IMPLICIT) for operation '='