- en
- Language: ru
- Documentation version: latest
AND
Оператор AND позволяет группировать несколько условий:
new_db.db> select * from switch where model = 'Cisco 3850' and mngmt_ip LIKE '10.255.%';
+----------------+----------+------------+-------------------+------------+-----------+
| mac | hostname | model | location | mngmt_ip | mngmt_vid |
+----------------+----------+------------+-------------------+------------+-----------+
| 0010.D1DD.E1EE | sw1 | Cisco 3850 | London, Green Str | 10.255.1.1 | 255 |
| 0020.A2AA.C2CC | sw2 | Cisco 3850 | London, Green Str | 10.255.1.2 | 255 |
| 0040.A4AA.C2CC | sw4 | Cisco 3850 | London, Green Str | 10.255.1.4 | 255 |
| 0050.A5AA.C3CC | sw5 | Cisco 3850 | London, Green Str | 10.255.1.5 | 255 |
| 0030.A3AA.C1CC | sw3 | Cisco 3850 | London, Green Str | 10.255.1.3 | 255 |
+----------------+----------+------------+-------------------+------------+-----------+
5 rows in set
Time: 0.034s
OR
Оператор OR:
new_db.db> select * from switch where model LIKE '%3750' or model LIKE '%3850';
+----------------+----------+------------+-------------------+------------+-----------+
| mac | hostname | model | location | mngmt_ip | mngmt_vid |
+----------------+----------+------------+-------------------+------------+-----------+
| 0010.D1DD.E1EE | sw1 | Cisco 3850 | London, Green Str | 10.255.1.1 | 255 |
| 0020.A2AA.C2CC | sw2 | Cisco 3850 | London, Green Str | 10.255.1.2 | 255 |
| 0040.A4AA.C2CC | sw4 | Cisco 3850 | London, Green Str | 10.255.1.4 | 255 |
| 0050.A5AA.C3CC | sw5 | Cisco 3850 | London, Green Str | 10.255.1.5 | 255 |
| 0060.A6AA.C4CC | sw6 | C3750 | London, Green Str | 10.255.1.6 | 255 |
| 0030.A3AA.C1CC | sw3 | Cisco 3850 | London, Green Str | 10.255.1.3 | 255 |
+----------------+----------+------------+-------------------+------------+-----------+
6 rows in set
Time: 0.046s
IN
Оператор IN:
new_db.db> select * from switch where model in ('Cisco 3750', 'C3750');
+----------------+----------+-------+-------------------+------------+-----------+
| mac | hostname | model | location | mngmt_ip | mngmt_vid |
+----------------+----------+-------+-------------------+------------+-----------+
| 0060.A6AA.C4CC | sw6 | C3750 | London, Green Str | 10.255.1.6 | 255 |
+----------------+----------+-------+-------------------+------------+-----------+
1 row in set
Time: 0.034s
NOT
Оператор NOT:
new_db.db> select * from switch where model not in ('Cisco 3750', 'C3750');
+----------------+----------+------------+-------------------+------------+-----------+
| mac | hostname | model | location | mngmt_ip | mngmt_vid |
+----------------+----------+------------+-------------------+------------+-----------+
| 0010.D1DD.E1EE | sw1 | Cisco 3850 | London, Green Str | 10.255.1.1 | 255 |
| 0020.A2AA.C2CC | sw2 | Cisco 3850 | London, Green Str | 10.255.1.2 | 255 |
| 0040.A4AA.C2CC | sw4 | Cisco 3850 | London, Green Str | 10.255.1.4 | 255 |
| 0050.A5AA.C3CC | sw5 | Cisco 3850 | London, Green Str | 10.255.1.5 | 255 |
| 0070.A7AA.C5CC | sw7 | Cisco 3650 | London, Green Str | 10.255.1.7 | 255 |
| 0030.A3AA.C1CC | sw3 | Cisco 3850 | London, Green Str | 10.255.1.3 | 255 |
+----------------+----------+------------+-------------------+------------+-----------+
6 rows in set
Time: 0.037s