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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:32:20+00:00 2026-06-13T07:32:20+00:00

I am trying to write a database view that selects from 2 tables. Here

  • 0

I am trying to write a database view that selects from 2 tables. Here is an example:

USER_TABLE
- ID
- USER_NAME

FAMILY_TABLE
- ID
- FAMILY_NAME
- FATHER_USER_NAME
- MOTHER_USER_NAME
- GRANDFATHER_1_USER_NAME
... (multiple user name columns)

(The table writers didn’t associate via ID for some reason)

I essentially need to make a view that has each user listed, along with the names of the families they belong to. I have tried a number of things, but each seems to fail.

I first tried to union SELECT statements from the FAMILY_TABLE, but that took forever (see my previous post).

Then I tried to do an “or join”:

SELECT ut.USER_NAME, ft.FAMILY_NAME
FROM USER_TABLE ut
LEFT OUTER JOIN FAMILY_TABLE ft ON
(
    UPPER(ut.USER_NAME) = UPPER(ft.FATHER_USER_NAME)
    OR
    UPPER(ut.USER_NAME) = UPPER(ft.MOTHER_USER_NAME)
    ... (etc)
)

But that also takes a long time (took 22 seconds with just FATHER_USER_NAME and MOTHER_USER_NAME).

Can anyone suggest the most efficient way to write the query for the view I need? I am not sure how to make it quick.

FYI: Using Oracle 10g.

  • 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-13T07:32:21+00:00Added an answer on June 13, 2026 at 7:32 am

    This apparently works quickly (about 500 ms):

    SELECT ut.USER_NAME, familyInfo.FAMILY_NAME
    FROM USER_TABLE ut
    LEFT OUTER JOIN
    (
        SELECT
        (
            UPPER(ft.FATHER_USER_NAME) || ',' || 
            UPPER(ft.MOTHER_USER_NAME) || ',' || 
            ... (etc)
        ) AS MEMBERS,
        ft.*
        FROM FAMILY_TABLE ft
    ) familtyInfo
    ON familyInfo.MEMBERS LIKE ('%' || UPPER(ut.USER_NAME) || '%');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a query that joins a handful of tables from MySQL
I'm trying to write a query to pull some info from our database and
I'm trying to write a unit test for the database layer that validates the
I'm trying to write a query for a database that will left join a
I'm trying to write a program that would dump a whole lotus notes database
I'm trying to write some code for my database to enable a dropdown box
Overview: Trying to write a trigger for a SQL Server 2008 database. TableA and
I am trying to write a linq query in my Database.cs file. I find
I'm trying to write an MSBuild task to build a database using FluentNhibernate mappings.
I am trying to write to a table in my sqlite database in android

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.