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

  • Home
  • SEARCH
  • 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 6242267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:55:26+00:00 2026-05-24T11:55:26+00:00

I am using php with Mysql. I want to know what really is wrong

  • 0

I am using php with Mysql.
I want to know what really is wrong with query inside a query, what if i am not that much comfortable with using the INNER JOIN , and rather prefer writing multiple queries.
Am i doing something terribly wrong, or is it just to make it visually sound?

What I mean is…

$query="SELECT * FROM TABLE WHERE USER_ID=1";
$data=mysqli_query($dbc,$query);
$row=mysqli_fetch_array($data);
$query2="select * from TAble2 where some_id='{$row['user_id']}'";
$data1=mysqli_query($dbc,$query);
$row1=mysqli_fetch_array($data1);
// and then use $row1['column_name']
  • 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-24T11:55:27+00:00Added an answer on May 24, 2026 at 11:55 am

    The main benefit to combining as much as possible into a single query as opposed to iterating nested cursors is that round trips to the DB are relatively expensive.

    Using the nested cursors method in your question, you are preparing and executing n + 1 SQL statements, where n is the number of records in the initial result set.

    Where you to combine those queries with a join, you would only be preparing and executing one statement, no matter how large the result set.

    SELECT T1.foo, T1.bar, T2.baz
    FROM `TABLE` T1
    INNER JOIN `Table2` T2 ON T1.user_id = T2.some_id
    WHERE T1.user_id = 1
    

    You’re also placing less load on the database itself, particularly where statement caching is enabled.

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

Sidebar

Related Questions

I want to know how to display report by month using PHP and Mysql
I want to delete the most recent entry in MySQL using PHP, is there
i want to create tabs according to data from MySQL database using php for
I am using php, js, flash and mysql on 1 website. I want to
I want to run a web application on php and mysql, using the CakePHP
I'm currently using mysql w/ PHP because that's what I learned and haven't ever
i am using php with pdo , when i run a mysql query, is
I want to write my own URL shortener using php and mysql as a
I am creating a forum software using php and mysql backend, and want to
i am developing an online book store using php and mysql. now i want

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.