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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T20:46:25+00:00 2026-06-13T20:46:25+00:00

id | apples | oranges 1 111 p 2 112 p 3 113 p

  • 0


id | apples  | oranges
1    111       p
2    112       p
3    113       p
4    113       f
5    113       -
6    114       p
7    114       f
8    115       -
9    115       -
10   116       f

Looking for a way to return only the rows where:

  1. oranges contains value 'f' or no value (empty)
  2. there are duplicate values in apples
  3. at least one duplicate in applies contains value of 'p' in oranges.

The rows 4,5 & 7 in bold and italic are what I am after.

  • 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-13T20:46:27+00:00Added an answer on June 13, 2026 at 8:46 pm

    You need to do a self-join. Something like this:

    SELECT t1.*
    FROM myTable t1
    INNER JOIN myTable t2 ON t1.apples = t2.apples
    WHERE t1.oranges IN ('f', '-')
    AND t2.oranges = 'p'
    

    SQL Fiddle example

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

Sidebar

Related Questions

I have a simple array of stuff: $array = array(apples,oranges,strawberries); I am trying to
I might be mixing apples and oranges in this question since I'm noob in
I am trying to override Ruby's <=> (spaceship) operator to sort apples and oranges
i have a string that looks like this apples,fish,oranges,bananas,fish i want to be able
I have the following string: Apples Bananas Oranges Me 1 2 3 Brother 4
I have a URL pattern that needs to contain either APPLES or ORANGES in
Example: int main() { typedef int Oranges; typedef int Apples; /* ... a lot
I have a string similar to this.... $string = order apples oranges pears and
Say i have a combobox with apples apples pears oranges oranges i would like
I have a simple single-dimension array, let's say: fruits = [apples,bananas,oranges,peaches,plums]; I can loop

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.