简体   繁体   English

使用LIKE从多个表中获取数据

[英]Get data from multiple table with LIKE

I made a site with articles and I want to make a search area. 我创建了一个包含文章的网站,并且希望创建一个搜索区域。

So I create all but block on SQL I would like to retrieve the title of articles that contains 'MSA' or others in 6 different table 所以我在SQL上创建了所有代码块,但我想在6个不同的表中检索包含“ MSA”或其他代码的文章标题

Table name: 表名:

stiga
stihl
staub
goldoni
echo
toro

I tried with LIKE but he tells me an ambiguous field result :/ 我尝试过LIKE,但是他告诉我结果模糊:/

Use union all : union all使用union all

select title from stiga where title like '%MSA%'
union all
select title from stihl where title like '%MSA%'
union all
. . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM