How to avoid the union and use a left join

Hello

I have the following tables

{code}

create the table mainTable

(col1 varchar2 (2) varchar2 (2) col2, col3 varchar2 (2), col4 varchar2 (2));

create table secTable

(col1 varchar2 (2));

create the table secTable1

(col2 varchar2 (2));

create the table secTable2

(col3 varchar2 (2));

Insert in maintable

values ('a', 'b', 'this,' would be ');

Insert in maintable

values (', 'o', 'n', 'p');

insert into secTable

values ('a');

insert into secTable1

values ('b');

insert into secTable2

values ('c');

commit;

{code}

I made a request, drank, I would use join without clause union how can I change to receive the same result as the following query?

{code}

Select t1.*, 'bad value' | T1.Col1
from maintable t1
T1.Col1 left join t2 = t2.col1 sectable
where t2.col1 is null
Union of all the
Select t1.*, 'bad value' | T1.col2
from maintable t1
Join t2 left on t1.col1 = t2.col2 sectable1
where t2.col2 is null
Union of all the
Select t1.*, 'bad value' | T1. COL3
from maintable t1
Join t2 left on t1.col1 = t2.col3 sectable2
where t2.col3 is null

{code}

Thank you

Coco

Like this?:

SQL > SELECT col1, col2, col3, col4, xvalue

2 from (SELECT m0.*

3, NVL (t0.col1, 'bad value t0' | m0.col1) t0_col1

4, NVL (t1.col2, 'bad value t1' | m0.col2) t0_col2

5, NVL (t2.col3, 'bad value t2' | m0.col3) t0_col3

Maintable m0 6

LEFT OUTER JOIN sectable t0 7

8. WE (m0.col1 = t0.col1

9 AND t0.col1 IS NULL)

10 LEFT OUTER JOIN sectable1 t1

11. WE (m0.col1 t1.col2 =

12 AND t1.col2 IS NULL)

13 LEFT OUTER JOIN t2 sectable2

14. WE (m0.col1 = t2.col3

15 t2.col3 AND IS NULL))

16 UNPIVOT INCLUDES NULL values (xvalue wrongly IN (t0_col1, t0_col2, t0_col3))

17 ORDER BY xvalue

18.

COL1 COL2 COL3 COL4 XVALUE

------ ------ ------ ------ ---------------------------------------------------

a b c d bad value t0 a

m o n p bad value m t0

a b c d bad value t1 b

m o n p o t1 value of evil

a b c d bad value t2 c

m o n p value t2 n bad

6 selected lines.

Tags: Database

Similar Questions

  • How to avoid the 'union' to combine several sqls in one?

    Hi all

    I wrote to the sql below for a list of instructions which do not have audit defined on it.

    The sql works very well and gives the right output, but its effective not because I am struck dba_stmt_audit_opts several times.

    Is there anyway I can avoid the union and get the same result by pressing dba_stmt_audit_opts once or twice?

    Thanks for you help,
    Hozy

    ------------------------------------------
    Select * from
    (
    SELECT "audit_alter_any_table" as a PROPERTY, 'ALTER ANY TABLE' as VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "ALTER ANY TABLE"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_alter_user" as a PROPERTY, "ALTER USER' as VALUE,"NA"as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'ALTER USER'
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_create_role" as a PROPERTY, "CREATE ROLE" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "CREATE ROLE"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_create_user" as a PROPERTY, "CREATE USER" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'CREATE USER'
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_create_session" as a PROPERTY, "CREATE SESSION" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "CREATE SESSION".
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_drop_any_proc" as a PROPERTY, "DROP ANY PROCEDURE" as VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'DROP ANY PROCEDURE'
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_drop_any_table" as a PROPERTY, "DROP ANY TABLE" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'DROP ANY TABLE'
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_grant_any_priv" as a PROPERTY, "GRANT ANY PRIVILEGE" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "GRANT ANY PRIVILEGE"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_drop_any_role" as a PROPERTY, "DROP ANY ROLE" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'DROP ANY ROLE'
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_execute_proc" as a PROPERTY, "RUN the PROCEDURE" as VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = 'PROCEDURE '.
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_select_any_dic" as a PROPERTY, "SELECT ANY DICTIONARY" as VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "SELECT ANY DICTIONARY"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_grant_any_obj" as a PROPERTY, 'GRANT ANY OBJECT' as VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "GRANT ANY OBJECT"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_create_any_lib" as a PROPERTY, "CREATE ANY LIBRARY" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "CREATE ANY LIBRARY"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    Union
    SELECT "audit_create_lib" as a PROPERTY, "CREATE LIBRARY" as a VALUE, "NA" as value2
    OF dba_stmt_audit_opts
    WHERE audit_option = "CREATE LIBRARY"
    AND the success = "BY ACCESS.
    AND failure = "BY ACCESS.
    AND user_name IS NULL
    AND proxy_name IS NULL
    Having COUNT ()) = 0
    );

    Maybe something like that is what you are looking for:

    with options as (select 'ALTER ANY TABLE' col1 from dual union all
                     select 'ALTER USER' col1 from dual union all
                     .... -- all your audit_options
                     )
    select col1
    from   options
    minus
    select audit_option
    from   dba_stmt_audit_opts;
    
  • How to avoid the width and height of the code when inserting a picture

    Hello

    When I write html codes, I try to use "Ctr + ALt + I" to insert an image in the html code. "the codes will show width and height, for example" < img src = "Add - btn.gif" alt = "" "width ="76"height ="25"/ >", you can see, the code is not clean enough, I must remove the width and height by hand, is there a way I can insert a picture, without codes with the width and height.

    Thank you.

    Frank

    Hello

    First of all, welcome to the forum.

    is it possible that I can insert a picture, without codes with the width and height.

    No without changing the actual code of the marker or create an extension for editing. The first is not recommended because it will change it on all the html code and you must also change the tag for each doctype, and the second takes a lot of time and also needs to be done for each doctype.

    PZ

  • How to avoid the brain while using external redundancy.

    Hi all

    When Oracle creates disk to vote who is in external redundancy he writes only in a single drive even if we provide 3 disks for the disk group. In this scenario, what will happen during the expulsion of node. Is there a scenario of split brain.

    Ajay

    Ajay Vijayan wrote:

    I would like to know more about it. How do the multiple vote available in external redundancy disk?

    You can not. If you want three voice files, use a group configured for normal redundancy.

  • How to extend the network and using the Ethernet port to connect an older computer without wifi capability

    I have a wireless network with my Time Capsule, but also I have an old computer without wifi capability. Is it possible to share the connection to this computer that connects an airport express (model A1264) to extend it and the computer thought that the ethernet port on the Airport express?

    Thank you.

    Yes

  • Camileo S10 - how to avoid the 'information' during video playback on TV

    I just received my Camileo S10... very nice indeed... but how to avoid the track and reading data to be shown on the screen during playback on my TV...?

    Go to the movies, then before you start playing click the OK button. This also works when you save. You must do this before playing or recording.

  • How to avoid the glossy look and brilliant nostrils?

    I just built my first character of fuse and when I import into Photoshop, its nostrils are incandescent - as if the light shines through the back of his head!

    This fuse:

    Screen Shot 2016-01-17 at 04.27.53.png

    Becomes this in Photoshop:

    Screen Shot 2016-01-17 at 04.47.21.png

    I use a brush to set the nostrils, but have no idea how fix eye - of the suggestions?

    Even better - any ideas on how to avoid the glossy look and glowing nostrils?

    Thank you very much
    Malcolm

    Hey, Malcolm.

    Best way to explain what basically rendering 3D correctly really takes a lot of time, haha.  So that you may be able to work with the real-time 3D model and make changes quickly, we use two different rendering methods.

    There is an "Interactive" mode which is not like the beautiful light/shade, but is very fast - and that's what you see when you interact with the default template.

    Then, there is a mode "Raytraced" which is much more advanced calculations and stuff to give you a proper lighting / shadow.  Raytraced rendered may take time if so we can not use it all the time.

    In order to get the lights/shadows appropriate you need to perform a path Ray would make on the document.  Best way to do this:

    • Select your 3D layer in the layers panel
    • Make a selection in the drawing area to the area that you want to make (I recommend to test rendering of area to check the lighting/shadows before committing to make the whole layer).
    • Push the button is rendered at the bottom of the properties panel (it looks like a cube in a rectangle box, right next to the delete icon).

    There are other things that you must do if you want to get the best image search quality such as the addition of secondary lights!  You can add more lights in the 3D Panel using the small icon of light at the bottom.  Have 2-3 stage lights and adjusting their colors can make a big difference with the Assembly of your character in the scene.  Here is a small image for some comparisons:

    You can see the image with two lights a look much more realistic lighting and shadows and raytraced of one and two versions are much nicer and cleaner!

    Hope that helps!

  • How to set the position and size of the façade using the FPRunTimePosRunCustom method in a c# application?

    How to set the position and size of the façade using the FPRunTimePosRunCustom method in a c# application?

    I found a solution! -Set the size and position of the façade with the help of the

    File > VI properties > window running Position (in category list) > custom (in position of menu drop-down).

    then just accept the current position and size (leave the boxes checked) or set values you want directly (uncheck the boxes and fill in the numbers), or physically position and size the façade and use, the "set to current location" button and press "set size" current All that is easier for you.

    OK so it does not make use of the method VI Methods (Active X) FPRunTimePosRunCustom ([Position], [Size]) but if labview want to make him difficult to use then other means must be found.

  • I have all the games Age Of Empires, the versions of Windows and I changed to a Mac computers. How can I get the Mac version of the games and use my existing serial keys?

    I have all the games Age Of Empires, the versions of Windows and I changed to a Mac computers. How can I get the Mac version of the games and use my existing serial keys?

    Hello

    As you have bought Age of Empires for Windows OS, you will not be able to install the same copy of Age of Empire Windows version on Mac. However, you can contact the telephone support for confirmation on this issue.

    Here is the link:

    http://support.Microsoft.com/kb/295539

  • How to open the sounds and audio properties by using Labview

    Hi all

    How to open the sounds and audio properties of the control panel using the exe from system Labview vi.

    Y at - it all dll also open this property.

    If there is some dll which is which and how to program the dll to achieve my goal.

    Wow, you followed after a few...

    Open the command window is because to open the Control Panel, you need to execute it in the context of a shell, and it's what is done with the "cmd /c mmsys.cpl. To open the applet without using cmd you use RunDll32.exe, like this:

  • How to emulate the dialogue by using fields and pop-up screen

    Hi - I wanted to create a Popup screen that has similar abilities to the default value of dialogue - have a few buttons at the bottom of the screen and a main text field does not change. When the text is long, I want the same behavior as in the dialog box - to be able to scroll the text while seeing the arrows on the right, and at the same time I want the user to see the button at the bottom and be able to click on it.

    I tried using LabelField as RichTextField, but I failed to reproduce this behavior. If anyone has any ideas, I would be very grateful.

    Thank you

    Dan.

    When you view the PopupScreen (onDisplay() for the support of 4.2, onUiEngineAttached() a newer version) ask your 'default' setFocus() button.

    If you want to scroll through the text, but still see the buttons and I was one of them, you'll have to work harder: add your text field to a VerticalFieldManager (VERTICAL_SCROLL) and navigationMovement().  The Interior who call you can decide when and how much to scroll the text and use VerticalFieldManager.setVerticalScroll () followed by invalidate() program to scroll the NON_FOCUSABLE field.

  • I replaced my hard drive and format my computer before turning off the software PS.  It need my code series now, but I had lost.  How can I solve the problem and use the software again?

    I replaced my hard drive and format my computer before turning off the software PS.  It need my code series now, but I had lost.

    How can I solve the problem and use the software again?

    If you use a perpetual Photoshop and formatted your disc version of starting without disabling your activation of Photoshop, you also Adobe supports help you activate Photoshop once you retrieve your serial number.  The startup disk formatting would destroy that credential of Activation Photoshop machine which is registered in the database of the Adobe activation server. Which reduces the activation numbers you have to use.  If you have Photoshop installed on a second computer that means that you have no free activation available as well, even with your key you can't activated the machine.

  • How to avoid the launch of Labview when called by Teststand VI

    Hi, friends.

    I am a student of teststand. I wrote a few screws by Labview. Now, I want to invoke in teststand environment. But when I run the sequence. LabVIEW automatically launches. How to avoid the launch of Labview when I run the sequence?

    Thank you.

    I'm not sure that I follow what you're saying...  But it seems that when the VI is called, the LabVIEW Development software is started and you want to avoid this.

    If you create an executable file or a dll and that any call within TestStand, she should not call the development environment.  You must have the LabVIEW runtime engine installed on the target computer.

    For several years I used TestStand with LV, if my memory does not have to be precise.  I think that the above worked for me.  However, it seems that I remember something to have the LV code in debug mode, causing to open development environment... but it's a distant memory.    You do not use breakpoints where the LV VI is called, are you?

    R

  • How to avoid the report query needs a unique key to identify each line

    Hello

    How to avoid the error below

    The report query needs a unique key to identify each row. The supplied key cannot be used for this query. Please change the report attributes to define a unique key column.

    I have master-detail tables but without constraints, when I created a query as dept, emp table he gave me above the error.

    Select d.deptno, e.ename

    by d, e emp dept

    where e.deptno = d.deptno

    Thank you and best regards,

    Ashish

    Hi mickael,.

    Work on interactive report?

    You must set the column link (in the attributes report) to something other than "link to display single line." You can set it to 'Exclude the column link' or 'target link to Custom.

  • Question CP9: HTML5: Apple: Android: how to avoid the click on the Play button / tap?

    Hello

    Captivate 9.0.0.223: HTML5 draft.

    I'm sorry to ask this question, it's a little old chestnut on HTML5 in Apple iOS and Android.

    I have searched on the internet and forums for a solution underway, but could not find something that works.

    The problem is how to avoid the PLAY button, which forces the user to click / tap on it, when the project is accessible on an Apple or Android system.

    Play_icon.png

    The project will be published on the internet for use on any Windows, Apple or Android device.

    I have no control over the Web server or devices that will use the people, so that any changes to the software server or browser is out of the question.

    I have tried both a plain HTML5 and a responsive project, but neither avoid the Play button. I put an example of 1 slide on these links.

    http://www.hoffits.com/test_responsive/index.html

    http://www.hoffits.com/test_html5/index.html

    The bottom line is: ' is it possible to remove the need for the user to click / press the Play button?

    Thank you.

    Peter

    Cardiff

    In Wales

    UK

    In your normal HTML5, there is a line (I think it's 46) with this code:

    CP. DoCPInit();

    Add cp.movie.play (); Located below.

    so:

    CP. DoCPInit();

    CP. Movie.Play ();

Maybe you are looking for