Check the set value by bin : BIN « Function « SQL / MySQL






Check the set value by bin

      
mysql>
mysql> CREATE TABLE TEAMS_NEW
    ->       (TEAMNO     INTEGER NOT NULL PRIMARY KEY,
    ->        EmployeeNO   INTEGER NOT NULL,
    ->        DIVISION   SET ('first','second','third','fourth'));
Query OK, 0 rows affected (0.00 sec)

mysql>
mysql> INSERT INTO TEAMS_NEW VALUES (1, 27, 'first')
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (2, 27, 'first,third')
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (3, 27, 'first,third,sixth')
    -> ;
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (4, 27, 'first,fifth')
    -> ;
Query OK, 1 row affected, 1 warning (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (5, 27, NULL)
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (6, 27, 7)
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT INTO TEAMS_NEW VALUES (7, 27, CONV(1001,2,10))
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> SELECT * FROM TEAMS_NEW;
+--------+------------+--------------------+
| TEAMNO | EmployeeNO | DIVISION           |
+--------+------------+--------------------+
|      1 |         27 | first              |
|      2 |         27 | first,third        |
|      3 |         27 | first,third        |
|      4 |         27 | first              |
|      5 |         27 | NULL               |
|      6 |         27 | first,second,third |
|      7 |         27 | first,fourth       |
+--------+------------+--------------------+
7 rows in set (0.00 sec)

mysql>
mysql> SELECT    TEAMNO, DIVISION * 1, BIN(DIVISION * 1)
    -> FROM      TEAMS_NEW;
+--------+--------------+-------------------+
| TEAMNO | DIVISION * 1 | BIN(DIVISION * 1) |
+--------+--------------+-------------------+
|      1 |            1 | 1                 |
|      2 |            5 | 101               |
|      3 |            5 | 101               |
|      4 |            1 | 1                 |
|      5 |         NULL | NULL              |
|      6 |            7 | 111               |
|      7 |            9 | 1001              |
+--------+--------------+-------------------+
7 rows in set (0.00 sec)

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

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.Bin function for set