SELECT user_id as user_id, CONCAT(first_name,' ',last_name) as name
FROM users u
WHERE (first_name like '%r%' or last_name like '%r%')
UNION
SELECT provider_id as provider_id, provider_name as name
FROM providers
WHERE (provider_name like '%r%')
連接多個表使用上面的查詢,我得到在一個單一的select語句
user_id name
5 Richard
6 Rowen
12 Riley
21 Rowen providers
羅文提供商有PROVIDER_ID是21,但列名是USER_ID。我如何獲得provider_id的不同列名?
哇!它工作>你救了我的生命!非常感謝 ! – user2950179