[英]SQL: Check if column contains value from another SELECT statement
I wanted to join the below two tables: 我想加入以下两个表:
Table 1: 表格1:
---------
| Brand |
---------
| Honda |
| Dodge |
| Toyota|
---------
Table 2 Survey Table: 表2调查表:
------------------------------------------
|Ser| Comments |
------------------------------------------
| 1 | Honda is a reliable brand |
| 2 | The dodge Challenger is pure muscle|
| 3 | The new Toyota Corolla is a treat |
Now I want to join both these tables and get Table 3 : 现在我想加入这两个表并得到表3:
--------------------------------------------------
|Ser| Comments | Brand |
--------------------------------------------------
| 1 | Honda is a reliable brand | Honda |
| 2 | The dodge Challenger is pure muscle| Dodge |
| 3 | The new Toyota Corolla is a treat | Toyota|
How do I get Table 3? 我如何获得表3?
I am not being able to Compare both the Comments and the brand list to see if the comments contain the brand name and if yes take the Brand Name. 我无法比较评论和品牌列表,看看评论是否包含品牌名称,如果是,则采用品牌名称。 Any help would be great. 任何帮助都会很棒。
Use LIKE: Where UPPER(comments) LIKE '%' || 使用LIKE:其中UPPER(注释)LIKE'%'|| brand || 品牌|| '%' '%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.