比较一个列与另一列相似的列 [英] Compare Columns Where One is Similar to Part of Another

查看:29
本文介绍了比较一个列与另一列相似的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个 Select 语句,我可以在其中查看一列是否与另一列相似.

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. John Doe, CEO          John
2     Mr. Jake Doe, Exec        Jake
3     Mrs. Betty Smith, Chair     Jill

查询应该返回:

3 | Mrs.Betty Smith, Chair | Jill

但是我的只是返回表中的每一行:

However mine just returns every row in the table:

SELECT ID, FullName, FirstName
FROM tblNames
WHERE '%' + FirstName + '%' not like Fullname

有什么想法吗?

推荐答案

将 where 反转成这样:

Reverse the where, to something like this:

Fullname not like '%' + FirstName + '%' 

这篇关于比较一个列与另一列相似的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆