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 3221232
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:51:09+00:00 2026-05-17T15:51:09+00:00

My query is terribly big: SELECT n1.*, n2.rating, n3.*, n4.* FROM stats n1 INNER

  • 0

My query is terribly big:

SELECT n1.*, n2.rating, n3.*, n4.*
FROM stats n1
INNER JOIN members n2
ON n1.n_id = n2.id
INNER JOIN add_info n3
ON n1.n_id = n3.n_id
INNER JOIN other_table n4
ON n1.code = n4.code
WHERE n1.n_id = {$member_id} AND n1.code='{$some_code}'

Am I doing this correctly? If yes, can I make it better, more optimal? Because I really need information from all of 4 tables.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 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-17T15:51:10+00:00Added an answer on May 17, 2026 at 3:51 pm

    Honestly it doesn’t look too bad.

    When you ask about optimization, keep in mind that you can optimize code for different goals. For instance, you can optimize for performance–you want the code to accomplish its purpose as fast as possible. You can also optimize for code that’s easy to read. You can optimize for maintainability or testability. In the real world, you usually balance each of these goals to achieve something appropriate for the situation.

    If you find yourself joining all those tables often, consider using a view to make individual queries easier to write, read and maintain.

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

Sidebar

Related Questions

Query: SELECT u.user_id,r.totalVotes votes,r.totalPoints rating,@row:=@row+1 rank FROM mismatch_user u LEFT JOIN ratingItems r ON
Query: SELECT DISTINCT ([Equipment List].ID) AS Expr1, [Job Assignments].Job FROM [Equipment List] LEFT JOIN
Query 1: SELECT * FROM user_d1 WHERE EXISTS (SELECT 1 FROM `user_d1` WHERE birthdate
The query is: SELECT * FROM `news` ORDER BY `id` LIMIT ($curr_page * 5),
SELECT * from `employees` a LEFT JOIN (SELECT phone1 p1, count(*) c, FROM `employees`
We have the following code: select * from View1 where (Timestamp >= @x) and
I have a query that looks like the following: SELECT someString FROM ( SELECT
I have a terrible doubt. I have a query like this: SELECT id,fatherID FROM
I have the following query. SELECT MIN(col1) FROM table1 WHERE id1 IN (SELECT id2
I have this query to be run: string query = @SELECT * FROM hint

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.