Compare Columns Where One is Similar to Part of Another

后端 未结 7 1388
再見小時候
再見小時候 2020-12-05 07:35

I\'m trying to write a Select statement where I can see if one column is like part of another.

tblNames 
ID    FullName                   FirstName
1     Mr.         


        
7条回答
  •  长情又很酷
    2020-12-05 08:05

    This worked for me:

    SELECT *
    FROM `table`
    WHERE `col1` NOT LIKE CONCAT('%', `col2`, '%')
    

    Found it here: http://www.edmondscommerce.co.uk/mysql/compare-two-columns-in-mysql/

    Somehow it only worked correctly with the concat-function (?).

提交回复
热议问题