Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL:检查列是否包含来自另一个SELECT语句的值_Sql_Sql Server_Join_Ssms - Fatal编程技术网

SQL:检查列是否包含来自另一个SELECT语句的值

SQL:检查列是否包含来自另一个SELECT语句的值,sql,sql-server,join,ssms,Sql,Sql Server,Join,Ssms,我想加入以下两个表: 表1: --------- | Brand | --------- | Honda | | Dodge | | Toyota| --------- ------------------------------------------ |Ser| Comments | ------------------------------------------ | 1 | Honda is a reliable brand

我想加入以下两个表:

表1:

---------
| Brand |
---------
| Honda |
| Dodge |
| Toyota|
---------
------------------------------------------
|Ser|          Comments                  |
------------------------------------------
| 1 | Honda is a reliable brand          |
| 2 | The dodge Challenger is pure muscle|
| 3 | The new Toyota Corolla is a treat  |
--------------------------------------------------
|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|
表2调查表:

---------
| Brand |
---------
| Honda |
| Dodge |
| Toyota|
---------
------------------------------------------
|Ser|          Comments                  |
------------------------------------------
| 1 | Honda is a reliable brand          |
| 2 | The dodge Challenger is pure muscle|
| 3 | The new Toyota Corolla is a treat  |
--------------------------------------------------
|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|
现在我想加入这两个表并得到表3:

---------
| Brand |
---------
| Honda |
| Dodge |
| Toyota|
---------
------------------------------------------
|Ser|          Comments                  |
------------------------------------------
| 1 | Honda is a reliable brand          |
| 2 | The dodge Challenger is pure muscle|
| 3 | The new Toyota Corolla is a treat  |
--------------------------------------------------
|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|
我怎么才能拿到3号桌

我无法比较评论和品牌列表,以查看评论是否包含品牌名称,如果是,则使用品牌名称。任何帮助都会很好

像这样使用:
如果上面的(注释)像“%”| | brand | |“%”

你可以在
像上尝试
加入

SELECT * 
FROM Table1 t1 INNER JOIN Table2 t2 
ON t2.Comments like '%'+t1.Brand  +'%'