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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:20:55+00:00 2026-06-13T17:20:55+00:00

I wish to store the result of a SELECT statment into multiple variables. I

  • 0

I wish to store the result of a SELECT statment into multiple variables.

I know that the result of this query will always return 6 ints from 6 different rows.

I have tried using the following code :

SELECT id INTO @photo1, @photo2, @photo3, @photo4, @photo5, @photo6 
FROM album WHERE uploaded = @time AND scene_id = NEW.id;

album is a table.
uploaded is a field in album.
scene_id is a field in album.
id is the PRIMARY_KEY of album.

I have read that the number of variables must equal the number of fields. Which is obviously not the case in the above statement.

With this in mind, how would I overcome this problem?

This code is being used within a MySQL Trigger.

EDIT : Relevant Table schema as per request :

person   -- name of table   
id | approved -- id is PK

album   -- name of table
id | uploaded | scene_id  -- id is PK

Trigger is fired on change of approved from 0 to 1

  • 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-13T17:20:56+00:00Added an answer on June 13, 2026 at 5:20 pm

    You can join with the same table and ensure that each join will provide a new id, something like (eg. for two ids, but you will get the point):

    SELECT a1.id, a2.id INTO @photo1, @photo2
    FROM album a1 
    inner join album a2 on a2.scene=a1.scene and a2.upload=a1.upload and a2.id>a1.id 
    WHERE a1.uploaded = @time AND a1.scene_id = NEW.id;
    

    See SqlFiddle for a complete sql and test case.

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

Sidebar

Related Questions

Some code here, I want store mysql query result into an array with php,
I have a list of events that I wish to store the starting and
Lets say I have an object that has stringProp1, stringProp2. I wish to store
I wish to do the following: select * into tmptbl from sometable EXCEPT 'sometable'
I started by asking this question I wish to Select all rows which contain
I wish to run an SQL select statement similar to this SELECT * FROM
I am currently processing text/html data and I wish to store my results in
I have a case where I wish to store a list of resources in
I wish to do this using only XAML - How to add an additional
I am performing several selects and wish to compute the overlap. Example: SELECT id

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.