F
F
freshik3122018-07-22 19:32:40
MySQL
freshik312, 2018-07-22 19:32:40

How to make a selection from multiple tables?

Hello,
there are 2 tables:

withdraw
5b54b119base2186333530.png
incomes
5b54b13c8a6ef337814205.png

how do i find all records where user 1 and sort by date and time ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
moem, 2018-07-22
@moem

SELECT * FROM (
 SELECT w.user, w.amount, w.time, w.date
  FROM withdraw w
  WHERE w.user=1
 UNION
 SELECT i.user, i.amount, i.time, i.date
  FROM incomes i
  WHERE i.user=1
)
ORDER BY 3, 2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question