Overplot different tables

Copy the following code draws a line chart and clicking on the button "Add series", he adds a ScatterChart

It seems all ok, but just move scene left/right or up/down (left mouse click and drag) two X, Y axis and the graphics are moved.

How do I fix this code in order to obtain always the axis and the two overlap?

Thank you.
import java.util.Set;
import javafx.application.Application; 
import javafx.beans.property.SimpleDoubleProperty; 
import javafx.event.ActionEvent;
import javafx.event.EventHandler; 
import javafx.geometry.Side;
import javafx.scene.Group;
import javafx.scene.chart.NumberAxis; 
import javafx.scene.chart.XYChart; 
import javafx.stage.Stage; 
import javafx.scene.Scene; 
import javafx.scene.Node; 
import javafx.scene.chart.*; 
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent; 
import javafx.scene.layout.BorderPane; 
import javafx.scene.layout.StackPane;

public class RescalingSeries extends Application {

StackPane               mainGraphStackPane = null;
Button btnAdd;
BorderPane pane; 

XYChart.Series series1 = new XYChart.Series(); 

SimpleDoubleProperty rectinitX = new SimpleDoubleProperty(); 
SimpleDoubleProperty rectinitY = new SimpleDoubleProperty(); 

protected static Axis _duplicateAxis(Axis axis, Axis result) {

        result.setAnimated(axis.animatedProperty().get());
        result.setAutoRanging(axis.isAutoRanging());
        result.setLabel(axis.getLabel());
        result.setSide(axis.getSide());
        result.setTickLabelFill(axis.getTickLabelFill());
        result.setTickLabelFont(axis.getTickLabelFont());
        result.setTickLabelGap(axis.getTickLabelGap());
        result.setTickLength(axis.getTickLength());
        return result;
    }
 
    protected static ValueAxis _duplicateValueAxis(ValueAxis axis, ValueAxis result) {
        _duplicateAxis(axis, result);
        result.setLowerBound(axis.getLowerBound());
        result.setUpperBound(axis.getUpperBound());
        result.setMinorTickCount(axis.getMinorTickCount());
        result.setMinorTickLength(axis.getMinorTickLength());
        result.setTickLabelFormatter(axis.getTickLabelFormatter());
        return result;
    }
 
    /**
     * Duplicate a number axis.
     * @param axis The source axis.
     * @return A {@code NumberAxis}, never {@code null}.
     */
    public static NumberAxis duplicateNumberAxis(NumberAxis axis) {
        NumberAxis result = new NumberAxis();
        _duplicateValueAxis(axis, result);
        result.setTickUnit(axis.getTickUnit());
        result.setForceZeroInRange(axis.isForceZeroInRange());
        return result;
    }
 
    /**
     * Duplicate a category axis.
     * @param axis The source axis.
     * @return A {@code CategoryAxis}, never {@code null}.
     */
    public static CategoryAxis duplicateCategoryAxis(CategoryAxis axis) {
        CategoryAxis result = new CategoryAxis(axis.getCategories());
        _duplicateAxis(axis, result);
        result.setStartMargin(axis.getStartMargin());
        result.setEndMargin(axis.getEndMargin());
        result.setGapStartAndEnd(axis.gapStartAndEndProperty().get());
        return result;
    }
 
@Override 
public void start(Stage stage) { 
    
    final NumberAxis xAxisLC = new NumberAxis(1, 12, 1); 
    final NumberAxis yAxisLC = new NumberAxis(0.53000, 0.53910, 0.0005);
    yAxisLC.setSide(Side.RIGHT);
 
    yAxisLC.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxisLC) { 
 
        @Override 
        public String toString(Number object) { 
            return String.format("%7.5f", object); 
        } 
    }); 
 
    final LineChart<Number, Number> lineChart = new LineChart<>(xAxisLC, yAxisLC); 
 
    lineChart.setCreateSymbols(false); 
    lineChart.setAlternativeRowFillVisible(false); 
    lineChart.setAnimated(true); 
    lineChart.setLegendVisible(false);

    series1.getData().add(new XYChart.Data(1, 0.53185)); 
    series1.getData().add(new XYChart.Data(2, 0.532235)); 
    series1.getData().add(new XYChart.Data(3, 0.53234)); 
    series1.getData().add(new XYChart.Data(4, 0.538765)); 
    series1.getData().add(new XYChart.Data(5, 0.53442)); 
    series1.getData().add(new XYChart.Data(6, 0.534658)); 
    series1.getData().add(new XYChart.Data(7, 0.53023)); 
    series1.getData().add(new XYChart.Data(8, 0.53001)); 
    series1.getData().add(new XYChart.Data(9, 0.53589)); 
    series1.getData().add(new XYChart.Data(10, 0.53476)); 
    series1.getData().add(new XYChart.Data(11, 0.530123)); 
    series1.getData().add(new XYChart.Data(12, 0.531035)); 
   
    pane = new BorderPane(); 
    pane.setCenter(lineChart);
    mainGraphStackPane = new StackPane();
    mainGraphStackPane.getChildren().add(pane);
    Scene scene = new Scene(mainGraphStackPane, 800, 600); 
    lineChart.getData().addAll(series1); 
         
    stage.setScene(scene);         

    scene.setOnMouseClicked(mouseHandler); 
    scene.setOnMouseDragged(mouseHandler); 
    scene.setOnMouseEntered(mouseHandler); 
    scene.setOnMouseExited(mouseHandler); 
    scene.setOnMouseMoved(mouseHandler); 
    scene.setOnMousePressed(mouseHandler); 
    scene.setOnMouseReleased(mouseHandler); 
 
    Group root = new Group();
    btnAdd = new Button();
    btnAdd.setText("Add serie");
    root.getChildren().add(btnAdd);
    pane.getChildren().add(root);              
  
    btnAdd.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent event) {        
            NumberAxis xAxisBC = duplicateNumberAxis(xAxisLC);
            NumberAxis yAxisBC = duplicateNumberAxis(yAxisLC);
            ScatterChart<Number, Number> scatterChart = new ScatterChart<>(xAxisBC, yAxisBC); 
                        
            scatterChart.setAlternativeRowFillVisible(false); 
            scatterChart.setAnimated(true); 
            scatterChart.setLegendVisible(false);
            
            XYChart.Series series2 = new XYChart.Series();
            
            series2.getData().add(new XYChart.Data(1, 0.53185)); 
            series2.getData().add(new XYChart.Data(2, 0.532235)); 
            series2.getData().add(new XYChart.Data(3, 0.53234)); 
            series2.getData().add(new XYChart.Data(4, 0.538765)); 
            series2.getData().add(new XYChart.Data(5, 0.53442)); 
            series2.getData().add(new XYChart.Data(6, 0.534658)); 
            series2.getData().add(new XYChart.Data(7, 0.53023)); 
            series2.getData().add(new XYChart.Data(8, 0.53001)); 
            series2.getData().add(new XYChart.Data(9, 0.53589)); 
            series2.getData().add(new XYChart.Data(10, 0.53476)); 
            series2.getData().add(new XYChart.Data(11, 0.530123)); 
            series2.getData().add(new XYChart.Data(12, 0.531035));
            
            scatterChart.getData().addAll(series2);
                        
            Set<Node> chartNode = scatterChart.lookupAll(".chart-plot-background");
            for(final Node chr : chartNode){
                chr.setStyle("-fx-background-color: transparent;");                           
            }                                                
            chartNode = lineChart.lookupAll(".chart-plot-background");
            for(final Node chr : chartNode){
                chr.setStyle("-fx-background-color: transparent");                            
            }
            mainGraphStackPane.getChildren().add(scatterChart);
            
            xAxisBC.lowerBoundProperty().bind(xAxisLC.lowerBoundProperty());
            yAxisBC.lowerBoundProperty().bind(yAxisLC.lowerBoundProperty());      
        }
});
    
    stage.show(); 
} 

EventHandler<MouseEvent> mouseHandler = new EventHandler<MouseEvent>() { 
 
    @Override 
    public void handle(MouseEvent mouseEvent) { 
        boolean XScaling=false;
        boolean YScaling=false;

       if (mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED || mouseEvent.getEventType() == MouseEvent.MOUSE_MOVED ){ 
            LineChart<Number, Number> lineChart = (LineChart<Number, Number>) pane.getCenter(); 
            NumberAxis yAxis = (NumberAxis) lineChart.getYAxis(); 
            NumberAxis xAxis = (NumberAxis) lineChart.getXAxis(); 

            double Tgap = xAxis.getWidth()/(xAxis.getUpperBound() - xAxis.getLowerBound()); 
            double newXlower=xAxis.getLowerBound(), newXupper=xAxis.getUpperBound(); 
            double newYlower=yAxis.getLowerBound(), newYupper=yAxis.getUpperBound(); 
    
            double xAxisShift = xAxis.localToScene(0, 0).getX();
            double yAxisShift = yAxis.localToScene(0, 0).getY();
            
            double yAxisStep=yAxis.getHeight()/(yAxis.getUpperBound()-yAxis.getLowerBound());
            double CurrentPrice=yAxis.getUpperBound()-((mouseEvent.getY()-yAxisShift)/yAxisStep);
            
            double Delta=0.3;
            if(mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED && mouseEvent.getX()<xAxisShift+yAxis.getHeight() && mouseEvent.getY()<yAxisShift+yAxis.getHeight() && (XScaling==false || YScaling==false)){
               
  //==================================================== X-Axis Moving ==================================
                
                if(rectinitX.get() < mouseEvent.getX()){    
                    newXlower=xAxis.getLowerBound()-Delta;
                    newXupper=xAxis.getUpperBound()-Delta;
                }
                else if(rectinitX.get() > mouseEvent.getX()){    
                    newXlower=xAxis.getLowerBound()+Delta;
                    newXupper=xAxis.getUpperBound()+Delta;
                }    
                xAxis.setLowerBound( newXlower ); 
                xAxis.setUpperBound( newXupper ); 
                
//===================================================== Y-Axis Moving ====================================
         
                if(rectinitY.get() < mouseEvent.getY()){    
                    newYlower=yAxis.getLowerBound()+Delta/1000;
                    newYupper=yAxis.getUpperBound()+Delta/1000;
                }
                else if(rectinitY.get() > mouseEvent.getY()){    
                    newYlower=yAxis.getLowerBound()-Delta/1000;
                    newYupper=yAxis.getUpperBound()-Delta/1000;
                }
                yAxis.setLowerBound(newYlower);
                yAxis.setUpperBound(newYupper);
            }

 //----------------------------- Re-Scale the X-Axis when dragging below it ---------------------------------
          
            else if(mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED && mouseEvent.getY()>yAxisShift+yAxis.getHeight() ){
                if(rectinitX.get() < mouseEvent.getX()){    
                    newXlower=xAxis.getLowerBound()+Delta;
                    newXupper=xAxis.getUpperBound()-Delta;
                }
                else if(rectinitX.get() > mouseEvent.getX()){    
                    newXlower=xAxis.getLowerBound()-Delta;
                    newXupper=xAxis.getUpperBound()+Delta;
                }    
                xAxis.setLowerBound( newXlower ); 
                xAxis.setUpperBound( newXupper );           
            }
            
//--------------------------------- Re-Scale the Y-Axis when dragging to the left of it --------------------------
         
            else if(mouseEvent.getEventType() == MouseEvent.MOUSE_DRAGGED && mouseEvent.getX()> (xAxisShift + xAxis.getWidth())){
                if(rectinitY.get() < mouseEvent.getY()){    
                    newYlower=yAxis.getLowerBound()-Delta/1000;
                    newYupper=yAxis.getUpperBound()+Delta/1000;
                }
                else if(rectinitY.get() > mouseEvent.getY()){    
                    newYlower=yAxis.getLowerBound()+Delta/1000;
                    newYupper=yAxis.getUpperBound()-Delta/1000;
                }
                yAxis.setLowerBound(newYlower);
                yAxis.setUpperBound(newYupper);                
            }             
            rectinitX.set(mouseEvent.getX()); 
            rectinitY.set(mouseEvent.getY()); 
            
            if(mouseEvent.getEventType() == MouseEvent.MOUSE_MOVED && mouseEvent.getY()>yAxisShift && mouseEvent.getY()<yAxisShift+yAxis.getHeight() && mouseEvent.getX()>xAxisShift && mouseEvent.getX()<xAxisShift+xAxis.getWidth()){

            double XX=((mouseEvent.getX() - xAxisShift) / Tgap) + xAxis.getLowerBound();
            double YY=CurrentPrice;
            series1.setName(String.format("%.2g%n",XX) + ", " + String.format("%.4g%n",YY));
            }          
         } 
    } 
   }; 

public static void main(String[] args) { 
    launch(args);  
} 
}

In the event handler for your button link you the lowerBoundProperties of axes for your graphics to clouds of points in the corresponding properties for the axes of your chart. However, you also need to bind the upperBoundProperties:

        xAxisBC.lowerBoundProperty().bind(xAxisLC.lowerBoundProperty());
        yAxisBC.lowerBoundProperty().bind(yAxisLC.lowerBoundProperty());
        xAxisBC.upperBoundProperty().bind(xAxisLC.upperBoundProperty());
        yAxisBC.upperBoundProperty().bind(yAxisLC.upperBoundProperty());

Tags: Java

Similar Questions

  • How to get into two different tables in two columns of a listbox of multi column

    Hi all

    I have two different tables of the values assume that table 1A (1,2,3,4,5) and another table B (3,4,5,6,7). I want to write these tables in a multicolumn listbox such as 1st column would be A array and 2nd column table B.

    Thnx in advance

    Saki,

    I hope this helps to further

  • Process in two different tables in one page

    Hi all

    I have A form with a submit button, when I click on the button I want to send the data from two different tables. For example:

    REQ_ID: 221

    BOX_NUMBER: 2

    NOM_ELEMENT: APPLE

    COUNTRY_ORIGIN: USA

    I want to send all the information in table 1 and only REQ_ID and BOX_NUMBER in table 2.

    I tried to create processes two different which are:

    1. the usual process line DML for table 1 and;

    2. simple query 'Insert' SQL for table 2

    It seems fine, until I realized that when the user tries to update the BOX_NUMBER to 10 for example, only 1 table is updated and table 2 creates an another duplicate data instead of updating the old one! This also applies to my button Delete,.

    any idea to fix this problem?

    Thank you very much

    Vika

    Reread what you wrote and you would realize why 2nd table only "new lines".

    2. simple query "Insert into ' SQL for table 2

    If you need to UPDATE the table, then you must write a simple UPDATE statement.

    If you want to REMOVE from the table, then you must write a simple DELETE statement.

    I call this "DML DIY" - do it yourself DML

    (personally, I'd probably use MERGE for INSERT and UPDATE)

    MK

  • Select Max (Date) in two different tables...

    Dear all,

    I need the date of last update of two different tables, I mean max (date). We will update one table at a time. Updated once I need to take the last update.

    It can be either in table A table B.

    for example.

    Table A

    Date of the ID

    100 16/05/2014

    101 20/05/2014

    102, 22/05/2014

    Table B

    Date of the ID

    100 04/06/2014

    101, 26/05/2014

    102 21/05/2014

    I need the date of table B (101 26/05/2014) last updated date...

    Hello

    Another way, using much more GRAND:

    SELECT LARGER (max1, max2) x

    FROM (SELECT MAX (mydate) max1

    OF mytable_a

    )

    (SELECT MAX (myotherdate) max2

    OF mytable_b

    )

    ;

    Best regards

    Bruno Vroman.

  • Insertion of records in two different tables at the same time?

    Hello everyone, I have question about inserting records in two different tables at the same time, I'm looking for is by the way a unique id, which is created in the first statement insert to the second insert statement. Example of this problem:

    < cfquery name = "addRecords1" datasource = 'test' >

    Insert Into Table1 (name, Date, age)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.) "Name # ' >.

    < cfqueryparam cfsqltype = 'cf_sql_date' value = '#arguments. "Date # ' >.

    < cfqueryparam cfsqltype = "cf_sql_int" value = "#arguments. Age #"(>); "

    Select SCOPE_IDENTITY() as RecID;

    < / cfquery >

    < cfquery name = "addRecords2" datasource = 'test' >

    Insert into Table2(Company,City,Date,ID)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.Company #" >,)

    < cfqueryparam cfsqltype = "cf_sql_char" value = "" #City # ">,"

    < cfqueryparam cfsqltype = 'cf_sql_date' value = "" #Date # ">,"

    ( < cfqueryparam cfsqltype = "cf_sql_int" value = "How to pass RecID to insert in this table?" >).

    < / cfquery >

    In this example, I'm inserting records in table 1 and creation of IDENTITY SCOPE as RecId. I would like to pass this id and insert it in my table 2. This Id, I'll use in my second table as an identifier. If anyone knows anything about this please let me know. Thank you.

    );
    

    QueryName - DOT - ColumnName, so it should be:

    );
    

    HTH,

    ^_^

  • Oracle how to multiply two columns of different tables and results

    Oracle how to multiply two columns of different tables and get the result in the third column?

    I want to multiply all the lines of the quantinty column in the table of quantity with the relevant lines of the table of prices price column and get the result of multiplying in the third column. What should I use procedure trigerr? OR IS IT POSSIBLE HOW TO DO IT PLEASE HELP :D

    Edited by: 994229 2013-03-15 12:44
    /* Formatted on 3/15/2013 3:51:08 PM (QP5 v5.185.11230.41888) */
    CREATE TABLE mytable1
    AS
       (SELECT 1 id, 5 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 7 FROM DUAL
        UNION ALL
        SELECT 3, 8 FROM DUAL);
    
    CREATE TABLE mytable2
    AS
       (SELECT 1 id, 4 VALUE FROM DUAL
        UNION ALL
        SELECT 2, 12 FROM DUAL
        UNION ALL
        SELECT 10, 12 FROM DUAL);
    
      SELECT id,
             mytable1.VALUE,
             mytable2.VALUE,
             mytable1.VALUE * mytable2.VALUE product
        FROM mytable1 FULL OUTER JOIN mytable2 USING (id)
    ORDER BY id;
    
    ID     VALUE     VALUE_1     PRODUCT
    1     5     4     20
    2     7     12     84
    3     8
    10          12     
    
  • To find common data in 2 columns from two different tables.

    Hello

    Could someone help me with a querry to discover common data of 2 columns from two different tables?

    Thank you
    Rajesh

    Try as below.

    select col1 ,col2 from tab1
    intersect
    select col1 ,col2 from tab2;
    
  • Get the number of lines to different tables on the same line

    How can I get the number of lines for the different tables in a single line:

    SELECT count (A), count (B), count (C) table tb_a A, tb_b B, tb_c C;

    Thank you!

    Maybe if you want a little sophisticated look ;)

    select *
      from (select 'a' tbl_name,count(*) cnt
              from table_a
            union all
            select 'b' tbl_name,count(*) cnt
              from table_b
            union all
            select 'c' tbl_name,count(*) cnt
              from table_c
           )
     pivot (max(cnt) kount for tbl_name in ('a' as tbl_a,'b' as tbl_b,'c' as tbl_c))
    

    Concerning

    Etbin

  • How to find the same column name in different tables in the same schema

    Hello

    I find the 'ename' column name in different tables in the same schema.

    Thank you
    Nr

    Hello

    Try this query

    Select column_name, table_name from user_tab_columns where column_name = 'ENAME ';

    Award points and end the debate, if your question is answered or mark if she was...

    Kind regards

    Lacouture.

  • extraction of unique records of registration of two different tables

    Hello

    In the following two tables different www.testing.com code exists in both tables. I want to compare two different columns from two different tables for unique records.
    SQL> select unique(videoLinks) from saVideos where sa_id=21;
    
    VIDEOLINKS
    -----------------------------------------------------------------------
    www.testing.com
    
    SQL> ed
    Wrote file afiedt.buf
    
      1* select unique(picLinks) from saImages where sa_id=21
    SQL> /
    
    PICLINKS
    -----------------------------------------------------------------------
    test
    test14
    www.hello.com
    www.testing.com
    Thank you and best regards

    Try
    Select unique (videoLinks) in the saVideos where sa_id = 21
    Union
    Select unique (picLinks) in the saImages where sa_id = 21

  • Select cursor for update: multiple columns of different tables

    Hello

    I have two tables test1 and test2. I want to udpate the column (DEPT_DSCR) from the TEST1 and TEST2 using select for update and current tables of the... with the cursor.

    I have a code drafted as follows:
    DECLARE
    v_mydept1 TEST1. TYPE % DEPT_CD;
    v_mydept2 TEST2. TYPE % DEPT_CD;
    CURSOR C1 IS SELECT TEST1. DEPT_CD, TEST2. DEPT_CD OF TEST1, TEST2 WHERE TEST1. DEPT_CD = TEST2. DEPT_CD AND TEST1. DEPT_CD IS 'AA' FOR THE UPDATE OF TEST1. DEPT_DSCR, TEST2. DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1, v_mydept2;
    WHEN EXIT C1% NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR IS "PLSQL1" WHERE CURRENT OF C1;.
    SETTING A DAY TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1.
    END LOOP;
    COMMIT;
    END;

    The code above when it is run, declares that it runs successfully. But it does not update the columns you want [DEPT_DSCR].

    It works only when we want to update one or more columns of the same table... i. e by providing these columns after ' to UPDATE THE.
    I don't know what exactly is the problem when you want to update several columns of different tables.

    Can someone help me on this?

    user12944938 wrote:
    But it's more the notion of compensation and understanding.

    See the link below:
    http://download.Oracle.com/docs/CD/B10501_01/AppDev.920/a97269/pc_06sql.htm

    See the section RESTRICTION in the link above.

    Twinkle

  • can I display different tables at the same time?

    Hi all

    It is probably a newbie question, but is it possible to display different tables at the same time? I use SQL Developer 1.5.5 and I seem to be unable to display several tables at the same time, whenever I chose to open another table, the old table disappears. In other words, the Bulletin Board only switches to your new choice in the table list navigation. Any ideas anyone?

    Kind regards
    WF

    Menu item "Tools-> Preferences-> database-> ObjectViewer Parameters"; Make sure that "automatically freeze object viewer Windows" is checked.

    HTH.

    Hrsg.:.

  • Display and update of fields in different tables on the same page.

    I am facing two problems...

    (1) I have a report on which I show several fields of 4 different tables. For each row of data, there is a link to change on the first column. By clicking on the link change, I show you a form where I want to show the respective data. On the link change, even if I send you the data in the report, they do not appear on the form (what edit link is clicked). Also, there is only room for 3 items to ship through the link change.
    How to display the data correctly on the form? Is there another way to use the link change?

    (2) on the form, how do I update the data from different tables?

    Thank you

    Gargi

    Hi Lisa,

    The text of presentation on the INSTEAD OF triggers is in: [http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7004.htm#sthref7918]

    First of all, your SQL View contains a unique key so that your triggers and the two Apex know what is updated.

    Then, you can create instead of triggers for "instead of INSERT ON viewname", 'instead of UPDATE ON viewname' and 'DELETE ON viewname' on your SQL view. What do these triggers depends on what you need. In the trigger code, you refer to new data using: NEW.column_name and old data using: OLD.column_name (updates both: OLD and: NEW values).

    I'm not sure of the SEPARATE, the GROUP IN question. You would certainly have a unique key on each record. It could be that the DISTINCT or GROUP BY clause will have to be taken out of the SQL view and is part of the source of the region, so that the SQL view does nothing with the data other than to join several tables in a single "table" from the Primary Key/Foreign Key relationship.

    Andy

  • Create one of 2 different tables tables

    Hello

    How do I create a table of 2 different tables. The source tables have given and I want to include in the new table.
    I have try this:

    create the table NEW_ONE
    Select * from OLD_ONE
    Union
    Select * from OLD_ONE2;

    But it did not work properly :/

    Perhaps mean you this? Don't know what your join condition is?

    create table NEW_ONE as
    Select o1.id_oo, o1.name_oo, o2.id_002, o2.name_oo2
    of old_one o1, o2 old_one2
    where o1.id_oo = o2.id_oo2; -PLEASE CHECK THIS JOIN CONDITION

  • Select from different tables based on results

    How to do this in a select

    4 paintings

    T3 and t4 are identical in structure, but different data

    Select the id of the t1

    If exist in select t2 id

    Then select the data on t3

    on the other

    Select the data on t4

    create table t1 (ID);

    create table t2 (ID);

    create table t3 (varchar2 (10) col1, col2 varchar2 (10));

    create table t4 (varchar2 (10) col1, col2 varchar2 (10));

    Insert into t1 values (1);

    Insert into t1 values (2);

    Insert into t2 values (1);

    Insert into t3 values('DATA1','DATA2');

    Insert into t4 values('DATA3','DATA4');

    commit;

    Ive had the values 1 and 2 in t1. ID = 1 exist in t2, for this record, I want I want the values of t3 but where id = 2, the t4 values.

    Possible in a select?   Ive been playing with case statement but not anywhere near him

    Try this

    Select *.

    T3

    where exists (select 1 from T1 t where t.id in (select t2.id T2))

    ----

    Union of all the

    ----

    Select *.

    T4

    where does not exist (select 1 from T1 t where t.id in (select t2.id T2))

    -----

    Ramin Hashimzade

Maybe you are looking for