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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:01:38+00:00 2026-05-17T15:01:38+00:00

First, I have 4 table and columns such as feeds (id, type, type_id) feeds_normals

  • 0

First, I have 4 table and columns such as

  1. feeds (id, type, type_id)
  2. feeds_normals (id, type, content)
  3. feeds_links (id, type, title, link)
  4. feeds_youtubes (id, type, title, link, description, image)
  5. feeds_photos (id, type, link)

The table of “feeds type_id” is match/linkup “id” of normals, links, youtubes, photos

And

The table of “feeds type” is using the identified which table should be joined

For example:

feeds:
id: 1, type: "normal", type_id: 1
id: 2, type: "link", type_id: 1

feeds_normals:
id: 1, type: "normal", content: "this is a test"

feeds_links:
id: 1, type: "link", title: "This is a title", link: "http://yahoo.com"

Result:

id: 1, type: "normal", content: "this is a test", title: NULL, link: NULL
id: 2, type: "link", content: NULL, title: "This is a title", link: "http://yahoo.com"

Finally

In this case, how to write by SQL statement?

  • 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-17T15:01:38+00:00Added an answer on May 17, 2026 at 3:01 pm

    Something is wrong here, it may be the example or actual data. Here is how a super-type/subtype model usually looks like:

    alt text

    The matching data-example would be:

    Feeds:
    FeedId: 1, type: "normal"
    FeedId: 2, type: "link"
    
    Feeds_Normals:
    FeedId: 1, content: "this is a test"
    
    Feeds_Links:
    FeedId: 2, title: "This is a title", link: "http://yahoo.com"
    

    Note that the FeedID in a subtype table matches the one in the super-type. The Type field in subtype tables is optional — it allows for a check constraint to enforce that types do not get mixed in a subtype table.

    The query would look something like:

    select
          f.FeedID
        , n.Content      as NormalsContent
        , y.Title        as YouTubeTitle
        , y.Link         as YouTubeLink
        , y.Description  as YouTubeDescription
        , y.Image        as YouTueImage
        , k.Title        as LinksTitle
        , k.Link         as LinksLink
    from Feeds              as f
    left join Feeds_Normals as n on n.FeedId = f.FeedId
    left join Feeds_Links   as k on k.FeedId = f.FeedId
    left join Feeds_YouTube as y on y.FeedId = f.FeedId ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a contacts table which contains fields such as postcode , first name
I have three columns in my table - company_name, first_name, last_name . In the
I have the following style in an external CSS file called first.css table {
I have database with many tables. In the first table, I have a field
I have a table with columns 'id', 'resource_id', 'read_time', 'value' where 'value' is a
I have a table with three columns fk_id, sort_column, value_column for each fk__id_ I'd
I have a table with some columns. In each of them is a picture
I have a table with around 20 columns with mostly consisting of varchars and
I have a jTable with columns 'Job_no' and 'Status'with values such as: Job_no Status
I have some code that sorts table columns by object properties. It occurred to

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.