从多个MySQL表中搜索SQL查询

eom*_*off 5 mysql search

我正在尝试在多个表上执行搜索.

我将简化问题,说我有2个表Worker,并Customer都具有Id, Name, SurnameWorker已附加Position,所有的字段都varchar,除了Id它是Int.

如何进行将返回其中一行CustomerWorker其中一个字段包含输入的搜索字符串的行的查询.

我尝试过加入但是我还加入了行.

Nic*_*ssu 4

select id,name,surname,position,'worker' as tbl from worker where ..
union all
select id,name,surname,'','customer' from customer where ...
Run Code Online (Sandbox Code Playgroud)

这样你甚至可以知道结果属于哪个表。