使用LIKE(SQL)联接表 [英] Joining tables with LIKE (SQL)
本文介绍了使用LIKE(SQL)联接表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先我正在使用Oracle:
First of all I am using Oracle:
表一名称= tableone
表2名称= tabletwo
tableone
具有名为pizzaone
的列,tabletwo
具有名为pizzatwo
的列.我想将tableone
加入tabletwo
,其中pizzaone
在pizzatwo
名称中.
tableone
has a column named pizzaone
, tabletwo
has a column named pizzatwo
. I want to join tableone
to tabletwo
where pizzaone
is somewhere in the pizzatwo
's name.
我尝试过的事情:
select *
from tableone
join tabletwo on tableone.pizzaone like ('%' + tabletwo.pizzatwo + '%')
如何更正此查询?
推荐答案
请尝试使用以下语法:
select *
from tableone
join tabletwo on tableone.pizzaone like ('%' || tabletwo.pizzatwo || '%')
Oracle的字符串连接运算符是双管道(||).无效数字错误是因为Oracle需要'+'运算符的数字操作数.
Oracle's string concatenation operator is the double pipe (||). The invalid number error is because Oracle expects numeric operands for the '+' operator.
这篇关于使用LIKE(SQL)联接表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文