【发布时间】:2013-07-16 21:43:50
【问题描述】:
我在两个需要匹配的 mysql 表中有字段...在产品表中我有混合的字母/数字键 (product_code),例如 MM123,然后在集合表中我只有字母作为键 (collection_code ) 比如MM...
我试过这个:
select p.*
from product p, collection c
where p.product_code LIKE CONCAT(c.collection_code ,'%')
但是我得到了多个匹配的条目,因为 collection_code 有 M 和 MM 这样的条目,所以它返回 product_code = M123 和 product_code = MM123
我想我想要的是这样的:
select p.*
from product p, collection c
where p.product_code LIKE CONCAT(c.collection_code ,REGEXP '[^0-9 \.]+')
但我似乎无法完全理解
【问题讨论】: