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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:33:31+00:00 2026-06-01T00:33:31+00:00

In MySQL I’m trying to write a Stored Procedure which does the following: Run

  • 0

In MySQL I’m trying to write a Stored Procedure which does the following:

  1. Run a SELECT query which returns 1 row with 2 columns (so two pieces of information).
  2. Run an INSERT query which includes the two previous values returned and a few parameters which were passed into the stored procedure.

I was originally thinking I could store the two pieces of information from Step 1 into a variable, and then pass those into Step 2. After some reading though it seems that a variable in MySQL can only hold 1 piece of data. How can I get the 2 pieces of information from Step 1 into my INSERT statement in Step 2?

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-06-01T00:33:32+00:00Added an answer on June 1, 2026 at 12:33 am

    You can use INSERT INTO … SELECT.
    Example,

    INSERT INTO table1 
    SELECT col1, 
           col2, 
           value1, 
           value2 
    FROM   table2 
    

    Here you select col1, col2 from table2 and add 2 new custom values value1 and value2 to the result set. This new 4 columns get inserted in to the table1

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

Sidebar

Related Questions

MySQL, Trying to get a list of ip addresses, in order. this query select
Mysql Version 14.14 Distrib 5.1.41 I have a stored procedure that I am trying
Mysql's environment is following: character_set_database=big5 And when I send a SQL which contains tranditional
MySQL query is SELECT option as value, name as text from jos_components where parent
Mysql log has something like: 1649560 Query select * from actions where uniqueid like
MySQL server version 5.0.45. Consider the following: ( SELECT CASE WHEN t.group_id = 12
MySQL double while loop in php: $geta=mysql_query(SELECT id FROM table1 WHERE id<50); while($row=mysql_fetch_array($geta)){ while($row2=mysql_fetch_array($geta)){
mysql> select 28/4; +--------+ | 28/4 | +--------+ | 7.0000 | +--------+ 1 row
MySQL specifies the row format of a table as either fixed or dynamic, depending
mysql> select count(*) from table where relation_title='xxxxxxxxx'; +----------+ | count(*) | +----------+ | 1291958

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.