你好,你能帮帮我吗?我正在尝试合并两个除了某些字段之外根本没有关系的表,但主要思想是:
- 合并两个表
- 查找在其字段中包含“代码”的项目。但总是有错误说
#1054 - “where 子句”中的未知列“用户名”
SELECT role ,id,'' as type, '' as logo, username,'' as contactperson, lastname, '' as companyname, firstname, '' as address, description, address FROM users
UNION
SELECT '' as role, id,type, logo,'' as username, contactperson, '' as lastname, companyname, '' as firstname, address, description, website FROM company
WHERE type LIKE '%code%'
OR logo LIKE '%code%'
OR username LIKE '%code%'
OR contactperson LIKE '%code%'
OR lastname LIKE '%code%'
OR companyname LIKE '%code%'
OR firstname LIKE '%code%'
OR address LIKE '%code%'
OR description LIKE '%code%'
OR address LIKE '%code%')
我知道我的代码似乎有点矫枉过正,请帮帮我?或与我的问题相同的帖子?