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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:53:16+00:00 2026-06-03T13:53:16+00:00

I am trying to store sub-query result in session variable using MySQL, but the

  • 0

I am trying to store sub-query result in session variable using MySQL, but the issue is when I execute this Query like this (see the Query below) the error message will be show like this (see the Error message below).

I don’t know how to solve this issue.

(0 row(s) affected)
Execution Time : 00:00:00:343
Transfer Time  : 00:00:00:000
Total Time     : 00:00:00:343

Error Code : 1222
The used SELECT statements have a different number of columns

Execution Time : 00:00:00:000
Transfer Time  : 00:00:00:000
Total Time     : 00:00:00:000

Query

SET @post := 0;

SELECT user_name,
(SELECT COUNT(*) INTO @post  FROM post WHERE user_id = '23332'),
@post 
FROM `user_fans` WHERE user_id = '23332';
  • 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-03T13:53:18+00:00Added an answer on June 3, 2026 at 1:53 pm
    SET @post := 0;
    
    SELECT  user_name,
            @post := (SELECT COUNT(*) FROM post WHERE user_id = '23332'),
            @post 
    FROM    `user_fans`
    WHERE   user_id = '23332';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to store the user's ID in the session using django.contrib.auth.login . But
I'm trying to store member function pointers by templates like this: (This is a
I'm trying to store a url such as: http://localhost/pro_print/index.php#page=home in a variable, but I
I started by trying to store strings in sqlite using python, and got the
I'm trying to store an array value so that I can reuse when Sub
I am trying to better understand why this query optimization is so significant (over
I'm trying to query a table and get the results into a variable. With
I'm trying to do something like this in postgres: UPDATE table1 SET (col1, col2)
Im trying to store a list,collection of data objects in Hbase. For example ,a
I'm trying to store data in the following fashion with a string as the

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.