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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:29:43+00:00 2026-06-04T09:29:43+00:00

Many times just find the right article and reading it on StackOverflow helped me

  • 0

Many times just find the right article and reading it on StackOverflow helped me
through a lot of stuff that I didn’t know what to do with but for the first time,
I think I need to write one.
I’ve been searching for the correct answer on this prob but I’ve failed to find one.

So the bugger is that I’ve created 2 tables and one intersection table to relate them.

The idea behind is so simple(I’m almost embarrassed that I can’t solve this one).

One BBS article MAY have SOME attached files.
That means one article could have an attachment or not.
One article can have multiple attachments.

What I’ve been trying to do is

get the list of articles with all the information on its attachments but without duplicate rows.

Ok… I tried to put up the DDL but I coulndn’t format it correctly…

create table article(
id PK
some other stuff...
)

create table attachment(
id PK
physical_file_name 
etc...
)

and here is the intersection

create table article_attachment(
id PK(synthetic)
article_id FK
attachment_ID FK
)

I want to select all the articles whether it has or hasn’t any attachments
but if one article has multiple attachments I only need one of the attachments.
(it doesn’t matter which one of them)

Yes it sounds dumb but there is no DBA or SQL developer around here so I have to do all the
things… pretty messed up I’m trying my best

any wise ideas?

Thanks in advance

-p.s. –
I’ve tried something like…

with refined_table as(

  select file_id, row_number() over(partition by id order by id desc) as seq
  from consumer_file

)
select * 
from consumer_info ci 
left outer join consumer_file cf on cf.consumer_id = ci.id
left outer join refined_table rt on rt.file_id = cf.file_id
where rt.seq =1

this but I don’t really understand how it works

UPDATE

Here is what I tried at first. It keeps giving me
ORA-00979:not a GROUP BY expression
I looked for the solution for a long time. A few people suggested using
aggregation function or “Hint” (if that’s what it is…)

  with refined_table as(

      select file_id, row_number() over(partition by id order by id desc) as seq
      from consumer_file

    )

I mean this

Hmm any ideas ?

Many thanks all of you : )

SELECT 
    CI.id as article_id, 
    DF.id as attachment_id,  
    DF.PHYSICAL_NAME as file_name 
FROM 
    CONSUMER_INFO CI
LEFT OUTER JOIN 
    CONSUMER_FILE CF ON CF.CONSUMER_ID = CI.ID
LEFT OUTER JOIN 
    DEFAULT_FILE DF ON CF.FILE_ID = DF.id
GROUP BY 
   CI.ID
  • 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-04T09:29:44+00:00Added an answer on June 4, 2026 at 9:29 am

    If its only 1->N relationship from article -> attachment then you can modify the attachment as follows:

    create table attachment(
       id PK
       article_id FK 
       physical_file_name 
       etc...
    )
    

    You need a separate intersection table only if there were an N->N relationship between articles and attachments.

    UPDATE: However, if you still need to keep the N<->N relationship (as mentioned in your comment), then you can use the GROUP BY clause to GROUP results by article_id e.g:

    SELECT 
        article.id as article_id, 
        attachment.id as attachment_id,  
        attachment.physical_file_name as file_name 
    FROM 
        article 
    LEFT OUTER JOIN 
        article_attachment ON article_id = article.id 
    LEFT OUTER JOIN 
        attachment ON attachment_id = attachment.id
    GROUP BY 
        article_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Many times when I lose connection to my development server, I just log back
Many times I needed a set of pointers. Every time that happens, I end
Many times I see statements like following Y.CustomApp.superclass.render.apply(this, arguments); I know how apply works.
Many times i run time consuming PHP scripts that echo status updates like 'batch
I have heard it many times that garbage collection in PyS60 is not up
I have read so many times, here and everywhere on the net, that mutexes
I find myself in a quandry that I think I know the solution to
I've read through many threads and can't find anything like my issue here. I
I think this is a question that has been asked many times but I
Many times I use 'mqsc' for create MQ queue manager from script files but

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.