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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:50:14+00:00 2026-05-21T22:50:14+00:00

I have two sql queries: $query0=mysql_query(SELECT caseNumber FROM shipped_data WHERE palette=’P0′ AND shipInvoiceNumber=’2011/229′); $query1=mysql_query(SELECT

  • 0

I have two sql queries:

$query0=mysql_query("SELECT caseNumber FROM shipped_data WHERE palette='P0' AND shipInvoiceNumber='2011/229'");
$query1=mysql_query("SELECT caseNumber FROM shipped_data WHERE palette='P1' AND shipInvoiceNumber='2011/229'");

and using following php script to fetch data,

while($res0=mysql_fetch_array($query0))
{
    $r0=$res0['caseNumber'];
    $q0=mysql_query("INSERT INTO pallet  (P00) VALUES ('$r0')")or die("Error");
}
while($res1=mysql_fetch_array($query1))
{
    print  $r1=$res1['caseNumber'];
    $q1=mysql_query("INSERT INTO pallet  (P01) VALUES ('$r1')")or die("Error");
}

This is the result:

First query inserts rows 1-10 of the data for coloumn1
The second query inserts rows 11-20 of the data for coloumn2.

What I need is rows 1-10 to be also inserted in column2, instead of rows 11-20

How can I do this?

  • 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-21T22:50:15+00:00Added an answer on May 21, 2026 at 10:50 pm

    I might help you looking at your problem from a different point of view. You can also perform your needs without having to loop through the records. You can execute the following SQL queries with PHP, or – if you have the ability – put this in a Stored Procedure, and call that.

    The following SQL does the same as your PHP script.

    INSERT INTO pallet (P00) 
        SELECT caseNumber 
        FROM shipped_data 
        WHERE palette='P0' 
            AND shipInvoiceNumber='2011/229';
    
    INSERT INTO pallet (P01) 
        SELECT caseNumber 
        FROM shipped_data 
        WHERE palette='P1' 
            AND shipInvoiceNumber='2011/229';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name
I have a small sql question for you. I have two queries: SELECT tbl_CostPrevisions.Month,
I have two SQL queries that I'm running from a C# winform, and I
I have these two SQL queries at the top of every page on my
i have 2 tables(result of two separate SQL queries and this result will be
I have two disconnected sql servers that have to have correlated queries run between
I have three tables and two seperate SQL queries which are working correctly and
I have two SQL queries with about 2-3 INNER JOINS each. I need to
Basically, I want have two separate SQL queries, but I want them to be
I currently have two almost identical SQL queries, which I use against my SQLITE3

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.