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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:17:33+00:00 2026-05-15T22:17:33+00:00

I need to execute a query that is highly dependent on several conditions what

  • 0

I need to execute a query that is highly dependent on several conditions what need to be checked by analyzing that data in other tables, the base goal is to return the rows from the tables if all of the conditions in the other tables are true, I am fed up with INNER joins LEFT joins and WHERE statement, i need to look up one table, if the returned value is 1, 0 or 4 or a set of values, i need to execute an other statement, and based on the resuts of that i need to execute one last statement which is my final result.

as far as functions are procedures are concerned, i studies the MySQL documentation like hell and all it gives me is this ::

DELIMITER $$

CREATE DEFINER=`root`@`localhost` FUNCTION `SimpleCompare`(n INT, m INT) RETURNS varchar(20) CHARSET latin1
BEGIN

    DECLARE s VARCHAR(20);

    IF n > m THEN SET s = '>';

    ELSEIF n = m THEN SET s = '=';

    ELSE SET s = '<';

    END IF;

    SET s = CONCAT(n, ' ', s, ' ', m);

    RETURN s;

  END

Now this is so plain, i dont even know where to start, I the “returns varchar(20)” what does it need to be if im expecting it to return a table of 10 rows and not a VARCHAR(20), what do I declare “DECLARE s VARCHAR(20);” as if i want it to be a table not a VARCHAR(20).

the (n > m) after the “IF” how to i replace it with my own query ,
and after I do that, the “THEN SET s = '>'” how do i set s = to the query results ?, this is driving me crazy the syntax is beyond me, and the documentation does not explain anything.

Thanks in advance

  • 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-15T22:17:33+00:00Added an answer on May 15, 2026 at 10:17 pm

    To my knowledge, MySQL doesn’t support a table valued data type. The use of the function you posted would be:

    SELECT simplecompare(yt.n, yt.m) AS eval
        FROM YOUR_TABE yt
    

    …which would return:

    eval
    --------
    1 = 1
    2 < 3
    etc.
    

    SQL is set based, which is different from typical programming (procedural or OO).

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

Sidebar

Related Questions

I currently need to execute a database query that involves data from three separate
I need to execute in python a SQL query that adds a new column,
I need to execute MDX query from command line (MS AS 2005). I have
In an application I need to execute other programs with another user's credentials. Currently
I have any number of anchor links on a page that need to execute
I have three tables that I would like to query: Streams, Entries, and FieldInstances.
I need to execute an SQL query. If i have a query with multiple
I need to execute a sql query from within a c# class. I have
So this is my query, it selects data from 3 tables on 2 different
I need to execute a large set of SQL statements (creating a bunch of

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.