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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:31:29+00:00 2026-05-23T02:31:29+00:00

I would really appreciate a bit of help/pointers on the following problem. Background Info:

  • 0

I would really appreciate a bit of help/pointers on the following problem.

Background Info:

Database version: Oracle 9i

Java version: 1.4.2

The problem

I have a database table with multiple columns representing various meta data about a document.

E.g.:

CREATE TABLE mytable
(
document_id integer,
filename varchar(255),
added_date date,
created_by varchar(32),
....
)

Due to networking/latency issues between a webserver and database server, I would like to minimise the number of queries made to the database.

The documents are listed in a web page, but there are thousands of different documents.

To aid navigation, we provide filters on the web page to select just documents matching a certain value – e.g. created by user ‘joe bloggs’ or created on ’01-01-2011′. Also, paging is provided so triggering a db call to get the next 50 docs or whatever.

The web pages themselves are kept pretty dumb – they just present what’s returned by a java servlet. Currently, these filters are each provided with their distinct values through separate queries for distinct values on each column.

This is taking quite a long time due to networking latency and the fact it means 5 extra queries.

My Question

I would like to know if there is a way to get this same information in just one query?

For example, is there a way to get distinct results from that table in a form like:

DistinctValue    Type
01-01-2011       added_date
01-02-2011       added_date
01-03-2011       added_date
Joe Bloggs       created_by
AN Other         created_by
....             ...

I’m guessing one issue with the above is that the datatypes are different across the columns, so dates and varchars could not both be returned in a “DistinctValue” column.

Is there a better/standard approach to this problem?

Many thanks in advance.

Jay

Edit

As I mentioned in a comment below, I thought of a possibly more memory/load effective approach that removes the original requirement to join the queries up –

I imagine another way it could work is
instead of populating the drop-downs
initially, have them react to a user
typing and then have a “suggester”
style drop-down appear of just those
distinct values that match the entered
text. I think this would mean a)
keeping the separate queries for
distinct values, but b) only running
the queries individually as needed,
and c) reducing the resultset by
filtering the unique values on the
user’s text.

  • 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-23T02:31:30+00:00Added an answer on May 23, 2026 at 2:31 am

    This query will return an output as you describe above:

    SELECT DocumentID As DocumentID, 'FileName' As AttributeType, FileName As DistinctValue
     FROM TableName
    UNION
    SELECT DocumentID, 'Added Date', Added_date FROM TableName
    UNION
    SELECT DocumentID, 'Created By', created_by FROM TableName
    UNION
    ....
    

    If you have the privilege you could create a view using this SQL and you could use it for your queries.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would really appreciate if you could shed light on this problem. I have
Would really appreciate some help with this. I have an app which consists of
I would really appreciate some help based on the following image: Furthermore, I am
I would really appreciate any suggestions, no matter how simple or complex, to help
I would really appreciate it if some of you could help optimize my tables,
Really hope someone can help me as I'm a bit stuck :S I have
I would really appreciate to get your help on this, as I can't seem
I have searched and have found almost nothing, so I would really appreciate some
I would really appreciate some feedback on what I am trying to achieve: The
I would really appreciate if you would take a look at this piece of

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.