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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:28:17+00:00 2026-06-12T10:28:17+00:00

These are the two tables Fruit and Fruit_types .There is a m:n relationship between

  • 0

These are the two tables Fruit and Fruit_types.There is a m:n relationship between the two tables so we have the third table fruit_type_fruit which has the primary key from the above two tables. The tables look like this

Fruit
ID    NAME    
1    A
2    B
3    C

Fruit_type
ID    LABEL
1    CITRIC
2    DRUPES
3    UNCATALOGUED

Fruit_type_Fruit
Fruit_id    Fruit_type
1        1
1        2
1        3
2        1
3        3

Problem Statement: Some fruits even though they have a category(i.e label) get label as Uncatalogued.

For ex:-
A gets the following labels : Citric, drupes and uncatalogued.

    B has    citric ,

    C has    Uncatalogued. 

Now I need a query to delete all the records which have a suitable label but still have uncatalogued label too.
In the above example

A record which is uncatalogued should be deleted and not

A    Citric and    Drupes neither

C    Uncatalogued. 
  • 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-12T10:28:19+00:00Added an answer on June 12, 2026 at 10:28 am

    How about something like this

    SQL Fiddle DEMO

    DELETE ftf
    FROM fruit_type_fruit ftf
    WHERE Fruit_type_ID = 3
    AND Fruit_ID IN
        (
                SELECT *
                FROM (
                        SELECT DISTINCT Fruit_ID
                        FROM fruit_type_fruit f 
                        WHERE f.Fruit_type_ID = 3
                 ) ss
                WHERE Fruit_ID IN (
                        SELECT *
                        FROM (
                        SELECT DISTINCT Fruit_ID
                        FROM fruit_type_fruit f 
                        WHERE f.Fruit_type_ID <> 3
                 ) s)
      )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say I have these two tables: CREATE TABLE nodes ( id INTEGER PRIMARY
If I have these two tables: <table> <tr> <td>Small Length Content</td> </tr> </table> <table>
We have two tables Family and Member, the relation between these two is Family
I have two tables (using table variables for illustration. You can run these directly
I have these two tables Orders and Employees Orders Table OrderID EmployeeID 1 1
I have a database that has two tables. These two tables are defined as:
I have a SQL Server 2008 database that has two tables. These two tables
Consider these two tables: CREATE TABLE GAME_ROUNDS( RoundId int primary key NOT NULL, GameId
I have these two tables. Leave Table from_date to_date user_id 2011-12-01 2011-12-01 1 2011-12-01
I have these two tables. The connecting key is conID which is included in

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.