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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:13:56+00:00 2026-06-05T03:13:56+00:00

i just created a stored procedure that take a parameter(example id) and copies columns

  • 0

i just created a stored procedure that take a parameter(example id) and copies columns related to that id from one table to another table.
How can i create stored procedure that takes sub query results as parameter,database is mysql..

This is my example..i want to pass query that select id from table to procedure..

DELIMITER $$

DROP PROCEDURE IF EXISTS `test`.`sasi`$$

CREATE DEFINER=`root`@`localhost` PROCEDURE `sasi`(IN idno int(4))

    BEGIN
    INSERT INTO user5(id,email,address,fullname,gender,phonenumber)
    SELECT id,email,address,fullname,gender,phonenumber FROM user1  where id != idno;
    END$$

DELIMITER ;

call sasi(4);
  • 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-05T03:13:58+00:00Added an answer on June 5, 2026 at 3:13 am

    To pass the results of a query into your stored procedure, wrap the query in brackets.
    For example:

    call sasi((select max(id) from sometable where somecondition));
    

    You must make sure the query only returns one row and one column.

    Edited:

    If you want to call the procedure multiple times, once for each row, change your procedure to be a FUNCTION:

    CREATE FUNCTION sasi(idno int(4))
    RETURNS int(4)
    BEGIN
        INSERT INTO user5(id,email,address,fullname,gender,phonenumber)
        SELECT id,email,address,fullname,gender,phonenumber FROM user1  where id != idno;
        RETURN idno;
    END
    

    Then call it like this:

    select sasi(id)
    from table
    where ...
    

    sasi(id) will get called for every row matching the where clause.

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

Sidebar

Related Questions

Another developer created a stored procedure that is set up to run as a
I'm using entity framework 4. I have a stored procedure that just updates one
I have just created a report in Report Manager using a Stored Procedure which
What I'm trying to do is take the results from a stored procedure and
Hello All I am using infragsitics tree view control.I have one stored procedure that
I have a stored procedure (sproc) called resetflags. It takes an int parameter. Another
Below is a simplified example of a stored procedure I've created. DELIMITER // CREATE
I have a stored procedure that accepts an xml parameter (SqlDbType.Xml) that is being
I've created a package that contains a stored procedure that I plan to invoke
I created a cursor from the one that was described on this post: SQL

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.