如何根据 SQL Teradata 中 table 1 列中的值 table 2 中的 select 行?
How to select rows from table 2 based on values in column from table 1 in SQL Teradata?
我在 SQL Teradata 中有 table:
client | description
--------------------|-----------
John Simon |arg John Simon
Larry Foe |Larry Foe por
Judy Gap |payment 11
我只需要在“descpition”列中找到名称(来自“client”列)+“arg”或“por”的客户,无论是在名称之前还是之后。
所以使用上面的例子我只需要显示 John Simon 和 Larry Fore,因为他们的名字在列“description +”arg“或”por“中,不管是在名字之前还是之后。
我该怎么做?
一种方法是:
where description like '%' || client || '%' and
(' ' || description || ' ' like '% por %' or
' ' || description || ' ' like '% org %'
)
第二部分中的分隔符只是为了避免匹配“Portland”等名称。
我在 SQL Teradata 中有 table:
client | description
--------------------|-----------
John Simon |arg John Simon
Larry Foe |Larry Foe por
Judy Gap |payment 11
我只需要在“descpition”列中找到名称(来自“client”列)+“arg”或“por”的客户,无论是在名称之前还是之后。 所以使用上面的例子我只需要显示 John Simon 和 Larry Fore,因为他们的名字在列“description +”arg“或”por“中,不管是在名字之前还是之后。
我该怎么做?
一种方法是:
where description like '%' || client || '%' and
(' ' || description || ' ' like '% por %' or
' ' || description || ' ' like '% org %'
)
第二部分中的分隔符只是为了避免匹配“Portland”等名称。