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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:31:15+00:00 2026-06-06T17:31:15+00:00

I ran into a problem or maybe even a MySQL limitation. The situation is

  • 0

I ran into a problem or maybe even a MySQL limitation.

The situation is as follows:

I have an SP X, selecting related records based on 1 or 2 arguments. The SP returns a list of 0, 1 or more id’s. I wanna use that list in an IN clause like so:

SELECT
    *
FROM
    table
WHERE
    id IN (spX(y));

This gives me an error:

Syntax error or access violation: 1305 FUNCTION z.spX does not exist

The error is a bit vague: I’m confident it’s a syntax error rather than access violation or non-existence of the SP itself. If I CALL the SP directly I get my expected results.

This kinda feels like a dead end. My expectation was that MySQL would throw an error if the SP returned more than 1 column, not if it returned more than 1 row (in which case I could’ve used a FUNCTION instead and this would’ve worked straight away).

So, the question is: is there any way of using the SP’s result in an IN clause?

On a side note: I’m aware I could achieve the same result by simply joining the table and then add a new where clause to the existing query, instead of using the SP. However, the real problem here is that new functionality has to be added to the application, and not having to join in tons of queries, but using a SP instead is the way of least resistance.

  • 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-06T17:31:16+00:00Added an answer on June 6, 2026 at 5:31 pm

    I implemented the solution as proposed in the chat:

    https://chat.stackoverflow.com/rooms/12910/discussion-between-robin-v-g-and-hituptony

    What I do step by step:

    1. I put a placeholder in every query involved.
    2. On a higher level in my application I call the stored procedure. To clarify: there’re 2 things I know for sure when it comes to the SP:
    • It will always take 1 id as parameter.
    • It will always give 0 or more id’s back.
    1. I generate the IN() clause depending on the SP’s outcome.
    2. I replace the placeholder with the generated IN() clause and run my query.

    This way I can always add or alter the conditions in the SP itself, without changing the application logic/queries.

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

Sidebar

Related Questions

Maybe some of you could have ran into the same problem i did. Imagine
Never ran into this problem with jQuery before. I have the following: $(document).ready(function() {
I have ran into a bit of a problem with my understanding of the
We ran into a problem in a large, Java, Hibernate-based system last week. Our
I ran into this problem and I cant solve it. Basically Im making an
I ran into a problem with some C code like this: struct SomeType {
I ran into a problem loading the admin section of my django site with
I just ran into a problem with the version of JAX-WS in JDK 1.6.0
I just ran into a problem.. I'm trying to build a website at the
I'm learning ObjectiveC and ran into a problem relating to introspection. Basically, I'm looping

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.