2015-02-11 123 views
0

我试图找到标题中的大小与宽度和高度不一致的行。看看在标题栏中它是如何显示“11x14”或“16x20”的,但宽度和高度应该基本上切换?我试图找到这些行,所以我知道哪些要修复。如何使用正则表达式将一个字段与另一个字段进行比较?

nid  width height title 
4702676 14  11  Black V Groove 11x14 
4702682 20  16  Red V Groove 16x20 

这是我已经试过了,但它返回设定这样的结果(第一行不应该存在):

nid  width height title 
4702674 11  14  White/Tan 11x14 
4702676 14  11  Black V Groove 11x14 
4702682 20  16  Red V Groove 16x20 

SELECT nid, width, height, title 
FROM my_table 
WHERE CONCAT(field_rm_width_value, "x", field_rm_height_value) != title REGEXP '^(\d)*x(\d)*' 

回答

1

试试这个:

SELECT nid, width, height, title 
FROM my_table 
WHERE title like(CONCAT('%',height,'x',width))  
1

这应该工作:

SELECT nid, width, height, title 
FROM `my_table` 
WHERE title NOT LIKE CONCAT('%', width, 'x', height) 

Sele ct标题用宽度和高度值的组合完成的所有行

相关问题