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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:04:43+00:00 2026-05-30T19:04:43+00:00

I have to write a query which will display the top 25 game_id which

  • 0

I have to write a query which will display the top 25 game_id which are under specific genre.
Database table is like

| id | genre_id | game_id | is_primary |
----------------------------------------
  1    6000       12345      0
  2    6007       12345      1
  3    6000       23492      0
  4    6007       82837      1
----------------------------------------

Here you can see that record 1 and 2 have same game_id for both is_primary = 0 and 1. What i have to do is to execute a query having both the genre_id with me and i have to fetch the game_id which falls under both. Means game_id which have 6000 as genre_id and is_primary=0 and 6007 as genre_id with is_primary=1.

Searched on net but no success.

I tried this query

 SELECT game_id FROM table_name WHERE 
(SELECT game_id FROM table_name WHERE genre_id=6000 AND is_primary=0) 
AND ganre_id=6007 AND is_primary=1;

But this query is giving error as Subquery returns more than one value.

  • 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-30T19:04:45+00:00Added an answer on May 30, 2026 at 7:04 pm

    Try this query (UPDATED)

    SELECT game_id FROM table_name WHERE game_id IN(SELECT game_id FROM table_name WHERE genre_id=6000 AND is_primary=0)
     AND ( ganre_id=6007 AND is_primary=1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok. I have my query written finally for my php file (which will write
I have been asked in an interview to write a SQL query which fetches
I'm trying write a query to find records which don't have a matching record
I have three tables. This query will write down the right answer (x-lines for
Got a problem with a query I'm trying to write. I have a table
I'm creating a query that will display information for a record which is derived
I have a table which is some thing like below.. Date ID 2009-07-01 1
I am trying to write a LINQ query which will return true if there
I have a table of transactions which will occasionally have duplicate entries. If/When an
I'm trying to write a query which will get the maximum scores for 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.