今天在LeetCode上看到一道sql的题目。

查询ID为奇数的记录。以前没想过这种情况,惭愧。

mysql 查询奇偶数

select id,movie,description,rating from cinema
where description != 'boring'
and id&1
order by rating desc

 

查找id为奇数的行:

 select * from tablewhere id&1 ;

查找id为偶数的行:

select * from table where id=(id>>1)<<1;

2.conv 函数:二进制,八进制,十六进制,十进制之间的转换

二进制--》十进制:

select conv(101010,2,10);

十进制--》十六进制:

select conv(999,10,16);

 

相关文章:

  • 2021-11-23
  • 2021-10-12
  • 2021-11-08
  • 2021-07-13
  • 2021-10-20
  • 2022-12-23
  • 2021-08-24
猜你喜欢
  • 2021-10-31
  • 2022-01-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-12
  • 2021-06-23
相关资源
相似解决方案