我正在尝试在多个表上执行搜索.
我将简化问题,说我有2个表Worker,并Customer都具有Id, Name, Surname和Worker已附加Position,所有的字段都varchar,除了Id它是Int.
如何进行将返回其中一行Customer或Worker其中一个字段包含输入的搜索字符串的行的查询.
我尝试过加入但是我还加入了行.
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)
这样你甚至可以知道结果属于哪个表。
| 归档时间: |
|
| 查看次数: |
3777 次 |
| 最近记录: |