我有一张表pub
,它看起来像下表:
+------------+----------------------------------+
| pub_id | pub_name |
+------------+----------------------------------+
| P0010101 | Jex Max Publication |
| P0020101 | BPP Publication |
| H0030102 | New Harrold Publication |
| H0040101 | Ultra Press Inc. |
| P0050101 | Mountain Publication |
| P0060103 | Summer Night Publication |
| P0070104 | Pieterson Grp. of Publishers |
| P0080102 | Novel Publisher Ltd. |
+--------+--------------------------------------+
我希望使用AND
子句进行过滤,其中pub_id
列{<1}}包含第1至第2 字母,P0
位于0101
来自整个句子的第3至第6 封信。
我试过了:
SELECT pub_id, pub_name FROM pub WHERE LEFT(pub_id,2) = 'P0' and pub_id LIKE '%0101%'
但结果是这样的
+------------+----------------------------------+
| pub_id | pub_name |
+------------+----------------------------------+
| P0010101 | Jex Max Publication |
| P0020101 | BPP Publication |
| P0050101 | Mountain Publication |
+--------+--------------------------------------+
我对结果的期望如下:
+------------+----------------------------------+
| pub_id | pub_name |
+------------+----------------------------------+
| P0010101 | Jex Max Publication |
+------------+----------------------------------+