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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:28:32+00:00 2026-05-14T18:28:32+00:00

For a stored procedure, I want to do a SELECT, and store a column’s

  • 0

For a stored procedure, I want to do a SELECT, and store a column’s value into a variable.

How do I do this?

I want to do something like this:

    DECLARE countTemp INT;
    SET countTemp=(SELECT COUNT(Name) FROM mytable WHERE Name= var_name LIMIT 0,1);

OR, like this :

    DECLARE countTemp INT;
    SELECT countTemp=ColumnXYZ FROM mytable WHERE Name= var_name LIMIT 0,1;

But, I tried these and MySQL says my syntax is incorrect; how do I do something like 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-14T18:28:32+00:00Added an answer on May 14, 2026 at 6:28 pm

    Like this :

    DECLARE myvar nvarchar(50);
    
    SELECT ATextColumn INTO myvar FROM myTable LIMIT 1,1;
    
    SELECT CONCAT('myvar is ',myvar ,' .');
    

    http://www.java2s.com/Code/SQL/Procedure-Function/UseselectintotoassignvaluetoanIntegervariable.htm

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

Sidebar

Related Questions

I want to write a stored procedure like this Create Proc dbo.GetApplicantsByIDs as Select
I want to (loosely) have a stored procedure like select * from table where
Hi i have a store procedure, where i do a select query. I want
I have this stored procedure that I want to use for my SAP crystal
I want a stored procedure to execute so that it updates a specific column
I'm trying to modify a stored procedure hooked into an ORM tool. I want
I have a table variable in a stored procedure. What I want is to
I want to update a table's column using the results of a stored procedure
I have a Microsoft SQL stored procedure whose column name I want to set
I'm trying to write a stored procedure and depending on a certain column value,

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.