select name,uid,gid from user-> where name="bin";+------+------+------+| name | uid | gid |+------+------+------+..._mysql 中括号">
当前位置:   article > 正文

mysql中括号的作用_括号()的作用

mysql 中括号

括号()的作用,先执行括号里面的命令,提高优先级

括号里面有"与"和"或"时,"与"优先。

and 与 (2者都要满足)

or 或 (满足其一即可)

mysql> select name,uid,gid from user

-> where name="bin";

+------+------+------+

| name | uid | gid |

+------+------+------+

| bin | 2 | 0 |

+------+------+------+

mysql> select name,(uid+gid)/2 as pjz from user where name="bin";

+------+--------+

| name | pjz |

+------+--------+

| bin | 1.0000 |

+------+--------+

mysql> select name,uid,gid,(uid+gid)/2 as pjz from user where name="bin";

+------+------+------+--------+

| name | uid | gid | pjz |

+------+------+------+--------+

| bin | 2 | 0 | 1.0000 |

+------+------+------+--------+

mysql> select name,uid from user

-> where

-> name="root" and id=1 or uid=2; 先找到name=root并且id=1的记录,然后再找到或者uid=2的记录

+------+------+

| name | uid |

+------+------+

| root | 1 |

| bin | 2 |

+------+------+

mysql> select name,uid from user where name="root" and (id=1 or uid=2); 先找到id=1或者uid=2的记录,然后再从找到的结果里,找到同时满足name=root的记录

+------+------+

| name | uid |

+------+------+

| root | 1 |

+------+------+

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/574806
推荐阅读
相关标签
  

闽ICP备14008679号