Answer the question
In order to leave comments, you need to log in
How to merge two tables in a SELECT query?
There are two tables. Partially identical.
rates
----
percent: float
vip_users
----
user_id: int
percent: float
Each user in the bank has a rate of 3%. VIP users have 1%.
You need to pull the VIP rate for the user (if any) by blocking the default rate.
Something tells me that group by should be used.
But my head no longer cooks and I can think of nothing.
UPD: wrong architectural decision. mapit data is impossible. they are not identical. the question can be closed.
Answer the question
In order to leave comments, you need to log in
Combine tables using UNION. Then sort by rate and display unique ones.UNION already collects unique strings. UNION ALL - everything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question