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

  • Home
  • SEARCH
  • 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 383635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:18:07+00:00 2026-05-12T15:18:07+00:00

EDIT: Far simpler example. (Formerly titled: Oracle Column Injection) GOAL: Complete the query below

  • 0

EDIT: Far simpler example. (Formerly titled: Oracle Column Injection)

GOAL: Complete the query below generate the following results?

PURPOSE: Create a column dependent on an existing column in a table without putting the table in a subquery.

Rules:

  1. Restructuring the query to put tbl in a subquery is not an option.
  2. The query must use a,b->1; x->2; y->3, not simply join to 1,1,2,1,3.
  3. The subquery tbl must not be modified.

 

SELECT val, cat
  FROM (SELECT 'a' val FROM DUAL  UNION ALL
        SELECT 'b' val FROM DUAL  UNION ALL
        SELECT 'x' val FROM DUAL  UNION ALL
        SELECT 'b' val FROM DUAL  UNION ALL
        SELECT 'y' val FROM DUAL) tbl
   ... JOIN ( ... ) ON ...

 val | cat
-----+-----
 'a' |  1
 'b' |  1
 'x' |  2
 'b' |  1
 'y' |  3

Well, I got this far (below), but I cannot add a second LEFT JOIN.

SELECT val, cat
  FROM (SELECT 'a' val FROM DUAL  UNION ALL
        SELECT 'b' val FROM DUAL  UNION ALL
        SELECT 'x' val FROM DUAL  UNION ALL
        SELECT 'b' val FROM DUAL  UNION ALL
        SELECT 'y' val FROM DUAL) tbl
   LEFT JOIN ( SELECT 1 cat FROM DUAL ) ON val in ('a','b')

 val | cat
-----+-----
 'a' |  1
 'b' |  1
 'x' |  
 'b' |  1
 'y' |  
  • 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-12T15:18:07+00:00Added an answer on May 12, 2026 at 3:18 pm
    SELECT tbl.val, map.cat
      FROM (SELECT 'a' val FROM DUAL  UNION
            SELECT 'b' val FROM DUAL  UNION
            SELECT 'x' val FROM DUAL  UNION
            SELECT 'b' val FROM DUAL  UNION
            SELECT 'y' val FROM DUAL) tbl
       LEFT JOIN ( SELECT 'a' val, 1 cat FROM DUAL UNION
                   SELECT 'b' val, 1 cat FROM DUAL UNION
                   SELECT 'x' val, 2 cat FROM DUAL UNION
                   SELECT 'y' val, 3 cat FROM DUAL ) map ON map.val = tbl.val
    

    From your examples, I suspect you mean to use UNION ALL instead of UNION (in order to have 2 rows for val = ‘b’ appear in the result).

    Your “I got this far” example doesn’t even run as written — it needs parentheses around the IN list — and even once you fix that it doesn’t produce the output you show.

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

Sidebar

Ask A Question

Stats

  • Questions 197k
  • Answers 197k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This seems to have been a bug in MySQL with… May 12, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer It's an issue with .Net 1.1 and 2.0. I haven't… May 12, 2026 at 7:25 pm
  • Editorial Team
    Editorial Team added an answer You need some sort of dictionary that contains words that… May 12, 2026 at 7:25 pm

Related Questions

I'm reading in a large text file with 1.4 million lines that is 24
I've looked at this explanation on Wikipedia , specifically the C++ sample, and fail
I'm implementing 'check' constraints that simply call a CLR function for each constrained column.
How do map providers (such as Google or Yahoo! Maps) suggest directions? I mean,
I have to write a component that re-creates SQL Server tables (structure and data)

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.