Three-table join query solution

Source: Internet
Author: User
Three-table join query three tables abc when I connect, I must write a query statement based on table a, but I don't know how to write it. The problem is: if the ID of Table A does not exist in other tables, the query fails. Please give me some advice. The following two SQL statements are left by the former programmer. The last one is modified by me. But three-table join query
Three tables a B c

When connecting, I must write a query statement based on table a, but I don't know how to write it,

The problem is that if the ID of Table A does not exist in other tables, the query will fail.

Please give me some advice.

The following two SQL statements are left by the former programmer.
The last one is modified by me.
But there are problems.

The problem is as follows.

This was left by programmers.
CSS code
  SELECT *, SUM (B. nums) AS addsums, SUM (c. nums) AS clicksumsFROM dx_app_info aINNER JOIN 'dx _ app_add_count 'binner JOIN 'dx _ app_click_count 'c ON. app_id = B. app_idAND. app_id = c. app_idWHERE app_name LIKE '% online human biological clock query %' group by. app_id


The problem is that if B or c does not have a corresponding ID, the query will fail. I don't want to see this result.






SELECT *, SUM (B. nums) AS addsums, SUM (c. nums) AS clicksums
FROM dx_app_info
Inner join 'dx _ app_add_count 'B
LEFT[Color = #00FF00] [/color] JOIN 'dx _ app_click_count 'c ON a. app_id = B. app_id
AND a. app_id = c. app_id
WHERE app_name LIKE '% online human biological clock query %'
Group by a. app_id
LIMIT 0, 20

This is the SQL statement I modified,
It can be queried, but the execution time is too long to be accepted.

------ Solution --------------------
Okay, I got it.
------ Solution --------------------
I am also a person...
------ Solution --------------------
Try to avoid having LIKE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.