The following editor will bring you an example code for querying odd and even numbers using mysql. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.
1: Find rows with odd numbers
Quote
mysql> select * from forum_dummy where id&1 ; +----+-----------+------------+ | id | user_name | dummy_name | +----+-----------+------------+ | 1 | yang | ting | | 3 | yang3 | ting3 | +----+-----------+------------+ 2 rows in set (0.00 sec)
2: Find rows with an even number
citation
mysql> select * from forum_dummy where id=(id>>1)<<1 ; +----+-----------+------------+ | id | user_name | dummy_name | +----+-----------+------------+ | 2 | yang1 | ting1 | | 4 | yang4 | ting4 | +----+-----------+------------+ 2 rows in set (0.00 sec)
3: conv Function: Conversion between binary, octal, hexadecimal and decimal
1) Binary--》Decimal
Quote
mysql> select conv(101010,2,10); +-------------------+ | conv(101010,2,10) | +-------------------+ | 42 | +-------------------+ 1 row in set (0.00 sec) 2)十进制--》十六进制 引用 mysql> select conv(999,10,16); +-----------------+ | conv(999,10,16) | +-----------------+ | 3E7 | +-----------------+ 1 row in set (0.00 sec)
The above is the detailed content of Example code for querying odd and even numbers using mysql. For more information, please follow other related articles on the PHP Chinese website!