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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:06:29+00:00 2026-05-25T15:06:29+00:00

Hi I need help with nested if else statements in MySQL. Please verify if

  • 0

Hi I need help with nested if else statements in MySQL. Please verify if the code below are the same? The C code is what I want to be accomplished in MySQL. I don’t have syntax errors. But it seems that I am not getting the right result.

MySQL Stored Proc

IF top10_rank <= 10 AND top100_rank <=10 THEN SET temp_rank = 10;
ELSE SET temp_rank = 100;
END IF;


IF temp_rank = 10 THEN
  IF top10_rank_date > top100_rank_date THEN SET rank = top10_rank;
  ELSE SET rank = top100_rank;
  END IF;
ELSEIF temp_rank = 100 THEN SET rank = top100_rank;
ELSE SET rank = 0;
END IF;

C code

if(top10_rank <= 10 && top100_rank <=10)
{
    temp_rank = 10;
}
else
{
    temp_rank = 100;
}

if(temp_rank == 10)
{
    if(top10_rank_date > top100_rank_date)
    {
        rank = top10_rank
    }
    else
    {
        rank = top100_rank
    }
}
else if(temp_rank == 100)
{
    rank = top100_rank;
}
else
{
    rank = 0;
}
  • 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-25T15:06:30+00:00Added an answer on May 25, 2026 at 3:06 pm

    It seems that the pieces are equivalent without regarding such things as size of integer (? may be float) fields and handling of NULL values in SQL.
    Code looks not good:

    1) This code is unreachable:

    else
    {
        rank = 0;
    }
    

    2) It could be shortened – temp_rank could be inlined

    3) Probably you need use this function is SELECT, it could be rewritten with CASE operator – to make calls more effective

    4) To detect a problem, wrap the C and SQL pieces in functions and specify for which input parameters results are different.

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

Sidebar

Related Questions

i need help with disk_total_space function.. i have this on my code <?php $sql=select
Little help need with jquery sortable. I have a nested list like so: <div
I need some help with nested resource actions. I have three nested resources: Jobs,
I need help with some PHP code. I am retrieving data from a MySQL
I need help on this following aspx code aspx Code: <asp:Label ID =lblName runat
I need help understanding some C++ operator overload statements. The class is declared like
I need to add some collection routes for a nested resource. I have a
Please help me to refactore this Javascript code. There is big form for scheduled
I need help with the following code that requires me to: Declare 3 double
I need some help concerning nested attributes in models with 'has_one' relationship. Model Survey

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.