Mysql比较单个表中同一行中两列的值

时间:2021-06-30 13:17:25

I have been searching for a query to compare values in single rows in the same table.

我一直在搜索一个查询来比较同一个表中单行的值。

Example table:

SKU        Description   SKU   Category  
173406926  Widgets       1734  
137406927  Widgets-Blue  1734

I need to find the rows where the SKU number does not start with the SKU Category number (as in row two above)

我需要找到SKU编号不以SKU类别编号开头的行(如上面第二行所示)

3 个解决方案

#1


2  

SELECT  *
FROM    tableName
WHERE   NOT (SKU LIKE CONCAT(`SKU Category`, '%'))

#2


0  

You can try this-

你可以尝试这个 -

SELECT * from tblName where SKU number REGEXP '^SKU Category'

SELECT * from tblName其中SKU编号REGEXP'^ SKU类别'

#3


0  

select sku from tablename t where not (sku like concat(`sku category`, '%'))

Try that...

#1


2  

SELECT  *
FROM    tableName
WHERE   NOT (SKU LIKE CONCAT(`SKU Category`, '%'))

#2


0  

You can try this-

你可以尝试这个 -

SELECT * from tblName where SKU number REGEXP '^SKU Category'

SELECT * from tblName其中SKU编号REGEXP'^ SKU类别'

#3


0  

select sku from tablename t where not (sku like concat(`sku category`, '%'))

Try that...