Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 426067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:26:33+00:00 2026-05-12T19:26:33+00:00

Can I combine these 2 SQL statements? Currently running 2 queries. Trying to tighten

  • 0

Can I combine these 2 SQL statements? Currently running 2 queries. Trying to tighten up a bit.

First one:

SELECT * FROM (`cars`) 
JOIN `brands` ON `brands`.`br_id` = `cars`.`brand_id`
WHERE `cars`.`id` = '185707'

Second one:

SELECT ROUND(AVG(rating)) as avg_rating
FROM car_ratings WHERE car_id = 185707 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:26:33+00:00Added an answer on May 12, 2026 at 7:26 pm

    You can do this using group by:

    select cars.*,
           brands.*, 
           round(avg(car_ratings.rating)) as avg_rating
    from   (cars
        inner join brands on brands.br_id = cars.brand_id)
        left join car_ratings on car_ratings.car_id = cars.id
    where  cars.id = 185707
    group by cars.id
    

    Note that this is a MySQL extension to standard SQL; in standard SQL you would need to list all of the selected fields in the group by clause.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I combine these two SQL statements? SELECT SUM(hits01 + hits02 + hits03
Can I combine these two SQL queries into single query? query1 ALTER TABLE tableA
I know I can combine tables with sql queries, but that's not what I
In an MS-Access database with Table called NewTable3 can i combine these 3 sql
I am trying to combine a few SQL queries to reduce the number of
I'm trying to combine an insert sql statement with a select statement, I successfully
I'm trying to combine an insert sql statement with a select statement, I successfully
I want to combine the following queries into a single query: SELECT val FROM
Is there any way I can combine list of expressions into one? I have
How can I combine this two selectors: $(td.listas select:last option:selected) This doesn't work! What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.