Mega Code Archive

 
Categories / MySQL / Function
 

The first sort operator discussed is the BINARY operator

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='red'; +--------+-----------+ | ProdID | ProdColor | +--------+-----------+ |    101 | Red       | |    102 | red       | |    103 | RED       | |    104 | REd       | |    105 | reD       | +--------+-----------+ 5 rows in set (0.00 sec) mysql> mysql> SELECT * FROM ProductColors     -> WHERE ProdColor = BINARY 'red'; +--------+-----------+ | ProdID | ProdColor | +--------+-----------+ |    102 | red       | +--------+-----------+ 1 row in set (0.00 sec) mysql> mysql> drop table ProductColors; Query OK, 0 rows affected (0.00 sec)