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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:47:41+00:00 2026-05-27T16:47:41+00:00

I have 14 tables that describe a hierarchical XML data structure. One field is

  • 0

I have 14 tables that describe a hierarchical XML data structure. One field is a key for the row and another field is a foreign key to its parent. The remaining 60 fields are the same in each table.

I would like to get one large serial list of rows instead of horizontally adding the columns.

For example the following is set up to give me 6 columns. How can I serialize it into 3 columns and more rows?

SELECT ICN2.ICNID, ICN2.ICNTITLE, ICN2.PANE, ICN3.ICNID AS ICNID2,
    ICN3.ICNTITLE AS ICNTITLE2, ICN3.PANE AS PANE2
FROM ICN2
LEFT OUTER JOIN ICN3 ON ICN2.ICN2_PKEY = ICN3.ICN2_FKEY
WHERE ICN2.ICNID = N'65587'
  • 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-27T16:47:41+00:00Added an answer on May 27, 2026 at 4:47 pm

    Use an SQL UNION to create a single (aliased) result set, then apply the condition:

    SELECT * FROM (
        SELECT ICNID, ICNTITLE, PANE
        FROM ICN2
        UNION ALL
        SELECT ICNID, ICNTITLE, PANE
        FROM ICN3
        UNION ALL
        SELECT ICNID, ICNTITLE, PANE
        FROM ICN4
        ... ) A
    WHERE ICNID = N'65587'
    

    This is the syntax for mysql and postgres, but the exact syntax may vary depending on which database you are using.

    If you need to know which table the rows came from, add a constant to each row:

    SELECT * FROM (
        SELECT 'ICN2' as SOURCE, ICNID, ICNTITLE, PANE
        FROM ICN2
        UNION ALL
        SELECT 'ICN3', ICNID, ICNTITLE, PANE
        FROM ICN3
        UNION ALL
        ... ) A
    WHERE ICNID = N'65587'
    

    BTW UNION ALL preserves ordering and duplicate rows. Plain UNION sorts and removes duplicate rows. Chose which ever suits you best

    • 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 should be joined together by a foreign key relationship,
I've got a bunch of classes that describe database schema: Table,Field,ForeignKey. Tables have ForeignKeys
I have two tables, one for job deadlines, one for describe a job. Each
I have 3 MySQL tables that describe a game: gamelist {gameId, ... with Primary(gameId)
I have 2 tables: mysql> describe solution_sections; +---------------------+---------------+------+-----+---------+----------------+ | Field | Type | Null
I have 2 tables: mysql> describe solution_sections; +---------------------+---------------+------+-----+---------+----------------+ | Field | Type | Null
I have a set of Oracle tables that describe information about property owners. Owner
I have two tables, splits and dividends that describe events in the stock market.
I have the following 2 tables.. mysql> describe catalog_category_reference; +----------+---------+------+-----+---------+----------------+ | Field | Type
I have three denormalized tables that I have to take at face value (data

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.