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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:53:53+00:00 2026-06-10T00:53:53+00:00

i have 2 tables. table one: items table two: items_options now i need a

  • 0

i have 2 tables.

table one: items
table two: items_options

now i need a search for 2 options_ids on table two

SELECT i.id FROM items as i
INNER JOIN items_options as io ON i.item_id = i.id 
WHERE io.option_id = 60143 AND io.option_id = 60142  
ORDER BY i.xy ASC LIMIT 0,50

How can i do it without group by/having?

  • 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-10T00:53:54+00:00Added an answer on June 10, 2026 at 12:53 am

    It seems like you want OR or use an IN statement.

    SELECT i.id 
        FROM items as i
    INNER JOIN items_options as io
        ON i.item_id = i.id 
    WHERE io.option_id IN (60143, 60142)
    ORDER BY i.xy ASC 
    LIMIT 0,50
    

    OR

    SELECT i.id 
    FROM items as i
    INNER JOIN items_options as io 
        ON i.item_id = i.id 
    WHERE io.option_id = 60143 OR io.option_id = 60142  
    ORDER BY i.xy ASC 
    LIMIT 0,50
    

    You cannot have an option_id that has both values.

    EDIT: If you want both values you can use a UNION ALL query:

    SELECT x.id
    FROM
    (
      SELECT i.id, i.xy
      FROM items as i
      INNER JOIN items_options as io 
        ON i.item_id = i.id 
      WHERE io.option_id = 60143 
      UNION ALL
      SELECT i.id, i.xy
      FROM items as i
      INNER JOIN items_options as io 
        ON i.item_id = i.id 
      WHERE io.option_id = 60142  
    ) x
    ORDER BY i.xy ASC 
    LIMIT 0,50
    

    Or you could try joining on the items_options table twice:

    SELECT i.id 
    FROM items as i
    INNER JOIN items_options as io1 
      ON i.item_id = io1.id 
    INNER JOIN items_options as io2 
      ON i.item_id = io2.id 
    WHERE io1.option_id = 60143 AND io2.option_id = 60142  
    ORDER BY i.xy ASC 
    LIMIT 0,50
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, one called cart and one called items. Now I want
I have two mysql tables: Item containing items that one can buy: CREATE TABLE
I have two tables, one table is the items container, which holds all data
I have two tables : one table it matchs and the other is teams.
Quick method description: I have two tables, lets name them table ONE and table
I have two tables. One user table and one table in which results are
I have two tables. One table contains words. Other table contains points. table words:
In SQL Server 2008 I have two tables. One table for users: id_user -
I have two MySQL tables: One for items and another to log purchases. I'm
I have two tables in a database one named purchases and one named items

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.