Answer the question
In order to leave comments, you need to log in
How to make a join request?
I can’t enter the join in any way, and even there the left one, the right one is not clear, I need to make 2 requests
SELECT COUNT(*) FROM `table_1` WHERE `id`='7'
SELECT COUNT(*) FROM `table_2` WHERE `id`='7'
Answer the question
In order to leave comments, you need to log in
I can't figure out why to join them.
If you need one line:
SELECT COUNT(*) as t1_count, NULL FROM `table_1` WHERE `id`='7'
UNION
SELECT NULL, COUNT(*) as t2_count FROM `table_2` WHERE `id`='7'
select
COUNT(*) as t1_count,
t2.t2_count
FROM `table_1` t1
inner join
(
SELECT id, COUNT(*) as t2_count FROM `table_2` WHERE `id`='7'
) t2 on t2.id = t1.id
where t1.id = '7'
Without a table structure, there is nothing to help you. If you want a ready-made request, write entities and fields by which they can be glued, but you won’t be able to help you with such a spherical horse in a vacuum. Well, or deal with the union of sets.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question