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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:05:23+00:00 2026-05-30T08:05:23+00:00

I have two tables A and Band the relation between A to B is

  • 0

I have two tables A and Band the relation between A to B is A—>one-to-Many—>B

Normally i have one record of B for every record of A.

I am trying to write a query which would give me list of ONLY records of A which have more than ONE(MULTIPLE) record(s) in B.

I am very confused as I have only done basic sql queries and this one seems complex to me.

Could some one please guide me to correct answer or give me the solution.

edited:

ok i tried something like below and it gave me an error

SELECT SOME_COLUMN_NAME FROM A a, B b WHERE a.ID=b.ID and count(b.SOME_OTHER_COLUMN_NAME)>1;

ORA-00934: group function is not allowed here

I tried to search on the internet ad i am not allowed to use grouping in where clause and should go by using having. I am stuck here now.

  • 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-30T08:05:26+00:00Added an answer on May 30, 2026 at 8:05 am

    You haven’t specified which database system you are using (sql-server/mysql/sqlite/oracle etc) so this is a generic answer.

    In this form, list out all the columns of A explicitly in the SELECT and GROUP BY clauses. It normally generates a good straightforward plan in most DBMS. But it can also fail miserably if the type is not GROUP-able, such as TEXT columns in SQL Server.

    SELECT A.Col1, A.Col2, A.Col3
    FROM A
    JOIN B ON A.LinkID = B.LinkID
    GROUP BY A.Col1, A.Col2, A.Col3
    HAVING COUNT(*) > 1
    

    This other form using a subquery works for any column types in A and normally produces exactly the same plan.

    SELECT A.Col1, A.Col2, A.Col3
    FROM A
    WHERE 1 < (
        SELECT COUNT(*)
        FROM B
        WHERE A.LinkID = B.LinkID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables that are joined together. A has many B Normally you
I have two tables, one for routes and one for airports. Routes contains just
I have two tables, Band and Votes. Band has a name and an id,
I have two tables, one is a list of songs. The other is a
Have two sets of data (two tables) for patient records, one 1999-2003, the other
I have two tables - band and band2. Band: and band2: The columns are
Suppose I have two tables A and B and each one has only 1
I have two tables that I need to compare and update values in one
i have two tables products and reviews each product has several reviews linked by
I have two tables : teachers (teacher_id,teacher_name) courses (teacher_id,course_id) And I need to display

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.