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

  • Home
  • SEARCH
  • 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 6803635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:22:07+00:00 2026-05-26T19:22:07+00:00

I have following Problem SELECT * from map_user_sticker WHERE map_user_sticker.user_id = 7; +—-+———+————+ |

  • 0

I have following Problem

SELECT * from map_user_sticker WHERE map_user_sticker.user_id = 7;
+----+---------+------------+
| id | user_id | sticker_id |
+----+---------+------------+
| 35 |       7 |         55 |
|  3 |       7 |         30 |
| 32 |       7 |         49 |
| 33 |       7 |         52 |
| 34 |       7 |         43 |
| 36 |       7 |         50 |
+----+---------+------------+
6 rows in set (0.00 sec)


SELECT * FROM sticker;
+----+--------------------------------------------------+
| id | word                                             |
+----+--------------------------------------------------+
| 40 | I love Sonal                                     |
| 41 | Add User to Database                             |
| 39 | This is a dream Project                          |
| 33 | Narendra Sisodiya                                |
| 34 | Sourabh Parmar                                   |
| 30 | Sonal Sisodiya                                   |
| 42 | I love India                                     |
| 43 | I love Linux                                     |
| 44 | I hate Congress                                  |
| 45 | I love jQuery                                    |
| 48 | Modi will be the PM                              |
| 47 | Ramdev Baba is my Super Hero                     |
| 49 | हिन्दी से प्यार है |
| 50 | Linux is better then Windows                     |
| 52 | I am from Sehore                                 |
| 55 | I have 2 little kids - sadu and sonu             |
+----+--------------------------------------------------+
16 rows in set (0.00 sec)

I basically want to generate Result like

+----+--------------------------------------------------+----------+
| id | word                                             |  present |
+----+--------------------------------------------------+----------+
| 40 | I love Sonal                                     |  0       |
| 41 | Add User to Database                             |  0       |
| 39 | This is a dream Project                          |  0       |
| 33 | Narendra Sisodiya                                |  0       |
| 34 | Sourabh Parmar                                   |  0       |
| 30 | Sonal Sisodiya                                   |  1       |
| 42 | I love India                                     |  0       |
| 43 | I love Linux                                     |  1       |
| 44 | I hate Congress                                  |  0       |
| 45 | I love jQuery                                    |  0       |
| 48 | Modi will be the PM                              |  0       |
| 47 | Ramdev Baba is my Super Hero                     |  0       |
| 49 | हिन्दी से प्यार है                                      |   1      |
| 50 | Linux is better then Windows                     |   1      |
| 52 | I am from Sehore                                 |   1      |
| 55 | I have 2 little kids - sadu and sonu             |   1      |
+----+--------------------------------------------------+----------+
16 rows in set (0.00 sec)

Please Help me !!
I want to generate a extra column called “present”, based on following condition
If sticker_id from query1 == id from query 2 then present = 1
else present = 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-26T19:22:07+00:00Added an answer on May 26, 2026 at 7:22 pm

    Here the Answer I was wanted to get !

    Answer 1 –

    SELECT s.* , IF(FIND_IN_SET(7,(GROUP_CONCAT(m.user_id))) != 0 , 1,0) as present, COUNT(m.user_id) as totalUsers 
    FROM sticker s   
    LEFT JOIN map_user_sticker m  
    ON s.id = m.sticker_id 
    GROUP BY id;
    

    Answer 2 –

    SELECT id,word, (case when 7 in (select user_id from map_user_sticker WHERE map_user_sticker.sticker_id=sticker.id) then 1 else 0 end) as present 
    from sticker;
    

    I don,t know which one is fast and better

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

Sidebar

Related Questions

I have the following problem: I select data from a DB, and for each
I have the following sql (a simplification of the real problem): SELECT * FROM
I still have following problem EXPLAIN EXTENDED SELECT `item`.`id`, `item`.`timestamp`, `item`.`label` FROM item WHERE
I have the following code: (query added) $weight_table = mysql_query (SELECT * FROM .$prefix.weight
HI Guys, I have following problem. I'm trying to connect from my Iphone app
I have the following code: mysql_query(SELECT * FROM list WHERE name LIKE '%'$searchTerm'%' OR
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I have the following problem: my table is big enought (millions of data rows),
I have following problem: I have built a tabbar application with 4 tabs. I
I have following problem, Code: String a=Yeahh, I have no a idea what's happening

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.