The bitwise OR operator : OR « Function « SQL / MySQL






The bitwise OR operator

   
mysql>
mysql> CREATE TABLE Attributes
    -> (
    ->     UserID SMALLINT NOT NULL PRIMARY KEY,
    ->     Settings TINYINT UNSIGNED NOT NULL
    -> );
Query OK, 0 rows affected (0.01 sec)

mysql> INSERT INTO Attributes VALUES
    -> (101, 58),
    -> (102, 73),
    -> (103, 45);
Query OK, 3 rows affected (0.00 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql>
mysql>
mysql> UPDATE Attributes
    -> SET Settings=Settings | 1
    -> WHERE UserID=101;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql>
mysql> select * from Attributes;
+--------+----------+
| UserID | Settings |
+--------+----------+
|    101 |       59 |
|    102 |       73 |
|    103 |       45 |
+--------+----------+
3 rows in set (0.00 sec)

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

mysql>

   
    
    
  








Related examples in the same category

1.Use the bitwise OR (|) operator to manipulate the bit values.