现有两张表如下:
select * from KeyWord select * from Food
我想要实现如下效果:
select * from Food where Food.foodName like '%果%' or Food.foodName like '%杏%' or Food.foodName like '%蕉%'
从Food表中匹配出有KeyName表中关键字的水果名称。就如同实现了like in的效果。
你可以通过如下sql来实现:
select * from Food inner join KeyWord on Food.foodName LIKE '%'+KeyWord.KeyName+'%';
效果如下: