Home > Database > Mysql Tutorial > Example code for querying odd and even numbers using mysql

Example code for querying odd and even numbers using mysql

零下一度
Release: 2017-04-22 13:57:05
Original
3392 people have browsed it

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)
Copy after login

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)
Copy after login

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)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template