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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:23:46+00:00 2026-06-18T14:23:46+00:00

I am trying to solve another problem here . I was told by a

  • 0

I am trying to solve another problem here. I was told by a member that in order to find an answer to my problem I needed to change the query to match the SP. In order to do that I was told to declare variables so I am using variables like I am in the SP. my problem is I have read so much my eyes are hurting and I cannot figure out how to declare friggin variables.

Please help!!

This is what I have read so far:

resource 1,
resource 2,
resource 3, resource 4, resource 5

and I could go on an on. I am literally stuck. I am new to SQL and this is bugging me out. I do not have to use a SP but I would really like to so I can learn the dos and donts and hopefully learn enough to help others.

DECLARE zipcode VARCHAR(30)
DECLARE radius VARCHAR(30)
SET zipcode = 08360
SET radius = 50

SELECT C.CustomerName, C.MenuId
FROM Customers C
INNER JOIN (
  SELECT ZIPCODE, ( 3959 * ACOS( COS( RADIANS( (
    SELECT Z.LAT
    FROM ZipCodes Z
    WHERE Z.ZIPCODE =zipcode
    LIMIT 0 , 1
    ) ) ) * COS( RADIANS( LAT ) ) * COS( RADIANS( LNG ) - RADIANS( (

      SELECT Z.LNG
      FROM ZipCodes Z
      WHERE Z.ZIPCODE =zipcode
      LIMIT 0 , 1
    ) ) ) + SIN( RADIANS( (

    SELECT Z.LAT
    FROM ZipCodes Z
    WHERE Z.ZIPCODE =zipcode
    LIMIT 0 , 1
  ) ) ) * SIN( RADIANS( LAT ) ) ) ) AS distance
  FROM ZipCodes
  HAVING distance <radius
  ORDER BY distance
) AS RelevantCodes ON ( C.ZIPCODE = RelevantCodes.ZIPCODE )

I have tried so many combinations from what I have seen on the internet that I am starting to think its just too late in the night to do anything more. If you take a look at some of the resources I looked at you will see where I saw the difference between with ‘@’ and without.

  • 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-18T14:23:47+00:00Added an answer on June 18, 2026 at 2:23 pm

    If you want to create a stored proc, you’ll need to use the proper syntax.

    See: http://dev.mysql.com/doc/refman/5.5/en/create-procedure.html
    Note that inside the proc body you’ll need to terminate each and every statement with a ;.

    Because you’ll need to let MySQL know when the body proc ends and you’ll need to redeclare the delimiter into something that not a ;.
    This will prevent MySQL from interpreting your stored proc after the first ‘;’, but instead listen all the way up to the $$.

    Don’t forget to revert the delimiter back to the default after you’re done inputting the function.

    SET DELIMITER $$
    
    CREATE PROCEDURE QueryCustomerMenu(IN zipcode VARCHAR(30), IN radius VARCHAR(30))
    BEGIN
    
    DECLARE somevar VARCHAR(20);
    SET somevar = '456';
    
    SELECT C.CustomerName, C.MenuId
    FROM Customers C
    INNER JOIN (
      SELECT ZIPCODE, ( 3959 * ACOS( COS( RADIANS( (
        SELECT Z.LAT
        FROM ZipCodes Z
        WHERE Z.ZIPCODE =zipcode
        LIMIT 0 , 1
        ) ) ) * COS( RADIANS( LAT ) ) * COS( RADIANS( LNG ) - RADIANS( (
    
          SELECT Z.LNG
          FROM ZipCodes Z
          WHERE Z.ZIPCODE =zipcode
          LIMIT 0 , 1
        ) ) ) + SIN( RADIANS( (
    
        SELECT Z.LAT
        FROM ZipCodes Z
        WHERE Z.ZIPCODE =zipcode
        LIMIT 0 , 1
      ) ) ) * SIN( RADIANS( LAT ) ) ) ) AS distance
      FROM ZipCodes
      HAVING distance <radius
      ORDER BY distance
    ) AS RelevantCodes ON ( C.ZIPCODE = RelevantCodes.ZIPCODE );
    
    END $$
    
    SET DELIMITER ;
    

    Now you can call the stored proc with:

    CALL QueryCustomerMenu('09210','20');
    

    And it will return a resultset with the CustomerName and MenuID‘s.

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

Sidebar

Related Questions

Here is the problem that I am trying to solve. I have two folders
Here is the problem that I have been trying to solve, but I haven't
I'm trying to solve the following problem in Redis. I have a list that
I have a problem here that still cannot solve, the thing is I have
I am trying to solve this String manipulation problem, where I need to find
I'm trying to solve a problem similar to the one described here Initializing strongly
I've been trying to solve a slow trigger problem and now that I have
Here's a problem I've been trying to solve at work. I'm not a database
Here is the problem I'm trying to solve for my game. I have this
trying to solve a puzzle which i found here: http://zcasper.blogspot.com/2005/10/google-phone-interview.html the goal is to

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.