Simple select with "Or"

This is very basic but I can't find any helpful resources out there that really give in depth query examples.
I need a select statement that does something like:
select * from table where column1 = '1' and column2 = '2' and column3 = '3' and (column4 = '4' OR column5 ='4');
I also tried,
select * from table where column1 = '1' and column2 = '2' and column3 = '3' and column4 OR column4 in ('4');

user9179751 wrote:
This is very basic but I can't find any helpful resources out there that really give in depth query examples.
I need a select statement that does something like:
select * from table where column1 = '1' and column2 = '2' and column3 = '3' and (column4 = '4' OR column5 ='4');
I also tried,
select * from table where column1 = '1' and column2 = '2' and column3 = '3' and column4 OR column4 in ('4');Why you are using "table" as the name of the table? Table is an oracle reserved name, you cannot use it !
Also, this is Wrong ! Please try to improve your Sql skills.
and column4  OR column4  in ('4');
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
Connected as SYS
SQL>
SQL> CREATE TABLE "TABLE"
  2  (
  3  column1 NUMBER,
  4  column2 NUMBER,
  5  column3 NUMBER,
  6  column4 NUMBER
  7  )
  8  ;
CREATE TABLE "TABLE"
column1 NUMBER,
column2 NUMBER,
column3 NUMBER,
column4 NUMBER
ORA-00955 name is already used by an existing object
SQL> 

Similar Messages

  • Simple SELECT with a group by condition

    Hello guys
    How could I build a simple map based in the query below ?
    select ename, job, sal
    from emp
    where sal < (select avg(sal) from emp)
    What operators should I use ?
    Source -> Aggregator-> what else ... ?

    Thank you bwise. This helped me a lot.
    However, if you can yet help me, I'll be thankful
    My question is a little bit more complicated.
    I have 2 cursors in PL/SQL
    cursor c1 is
    select e.ename, d.dname, d.deptno
    from emp e, dept d
    where e.deptno = d.deptno;
    cursor2 c2 (p1 number) is
    select avg(salary) avg1
    from emp
    where deptno = p1;
    r1 c1%rowtype;
    r2 c2%rowtype;
    counter number(4):=0;
    begin
    counter := 0;
    open C1;
    loop
    fetch C1 into R1;
    exit when (C1%NOTFOUND);
    counter := counter + 1;
    open C2 (r1.deptno);
    fetch C2 into R2;
    update emp set dept_avg = r2.avg1
    where empno = r1.empno;
    more processing;
    end loop;
    end;
    Do you have any idea of how can implement this in a map ?
    Thank you
    Marcelo

  • Problem with SImple Select Query

    Hi
    I am trying to write a simple Select SQL to a table and find out whether certain data exist or not. I have done this before but now for some reason this one is not working.
    I started like this
    select single * from ANLH where ANLN1 = rec-Asset
                                                 and BUKRS = Comp_Cd.
    * Error Handler for non-existent empno in the database
      if sy-subrc = 0 or rec-asset = ''.
         rec_failed = 'T'.
         concatenate 'Asset does not exist' rec-asset into asst_err.
      endif.
    when i debugged the code i found out that sy-subrc  is returning 4 all the time. (i have passes some numbers in rec-Asset which i know doesn't exist in that table.
    So i have modified the code to see if its pulling anything.
    like this
    select single ANLN1 into v_Asset from ANLH where ANLN1 = rec-Asset
                                                 and BUKRS = Comp_Cd.
    * Error Handler for non-existent empno in the database
      if sy-subrc = 0 or rec-asset = ''.
         rec_failed = 'T'.
         concatenate 'Asset does not exist' rec-asset into asst_err.
      endif.
    in debug v_asset is always empty (for real number and for the madeup number)
    Please help.
    Thanks
    Edited by: Anwarul Kabir on Apr 3, 2008 9:27 PM
    Edited by: Anwarul Kabir on Apr 3, 2008 9:29 PM
    Edited by: Anwarul Kabir on Apr 3, 2008 9:30 PM

    Thanks for the answer. But i thought i was doing the same. Anyway I replaced my code with yours but result is the same. I also did this
    select single
    ANLN1 into v_Asset
    from ANLH where
    ANLN1 = '20000544'
    and BUKRS = '3000'.
    I did SE11 and entered the table name and i can see that data.
    but on my code i get sy-subrc=4 and v_Asset is blank
    again i tried with this madeup number which i know its not in the table
    select single
    ANLN1 into v_Asset
    from ANLH where
    ANLN1 = '2056555433544'
    and BUKRS = '3000'.
    Get sy-subrc=4 and v_Asset is blank...
    Is there anything special about the Table?

  • Text Area steals Focus from Text Field when selected with mouse

    I have created a very simple form with 4 spry validation elements here :: http://octopusdesign.net/contactus.html
    When I attempt to select the 'Your Email' text field using the mouse, focus is grabbed by the text area above it.
    It is only possible to get focus on the 'Your Email' text field by using tab.
    My best guess is that this is a bug in the framework.
    In addition to updating my spry libraries to 1.6 from 1.4 I've tried the following things::
    Reordering the elements in the form.
    Creating the elements in a different order.
    Replacing the validation elements with ordinary elements.
    None of these fixed the problem.
    Strangely, if I remove the validation text area there is no problem.
    If anyone can shed some light on this I would really appreciate it.
    Wisdom gratefully received.
    Chris

    Furthermore ::
    I've tried to reconstruct the form from scratch and discovered that if you have a validation text field and a validation text area in any order on the form, selecting the 2nd element with the mouse always results in the first element stealing the focus.

  • Simple Select statement in MS Access

    I am not able to get this simple select statement working in MS Access.
    "SELECT PhotoLocation from RfidData WHERE TeamID = '"+teamID ;
    It is using a variable called teamID which is a string.
    The error is java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression
    Please Suggest
    Thank You...

    Let's look at your code, shall we?
    public String readPhotoLoc(String teamID)
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
        Connection con = DriverManager.getConnection(dbURL,"","");
        PreparedStatement ps = con.prepareStatement("Select PhotoLocation from RfidData ");  // There's no bind parameter here, so setString will do nothing
    ps.setString(1,teamID);
    ResultSet rs = ps.executeQuery();  // what do you do with the ResultSet?  Nothing.  //You don't return anything,  either.  I doubt that this mess even compiles.
    }Here's one suggestion for how to write it properly:
    public String readPhotoLoc(Connection connection, String teamID)
        String photoLoc = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
        try
            String query = "SELECT PhotoLocation FROM RfidData WHERE TeamID = ?";
            ps = connection.prepareStatement(query);
            ps.setString(1,teamID);
            rs = ps.executeQuery();
            while (rs.next())
                photoLoc = rs.getString("PhotoLocation");
            return photoLoc;
        catch (SQLException e)
              e.printStackTrace();
               return null;
        finally
              try { if (rs != null) rs.close(); } catch (SQLException ignoreOrLogThis) {}
              try { if (ps != null) ps.close(); } catch (SQLException ignoreOrLogThis) {}
    }Make sure that the types of the columns match the Java types.
    %

  • Simple select query is taking a lot of time

    hi gems...
    my table has 7267563 rows...and i am doing a simple select * from table;
    but it is taking a lot of time nearly 25minutes but not completed...
    when i did select count(1) from table then it gave the result instantly also select * from table where rownum < 10 is also fine...even when i am selecting all the records using rownum i.e. select * from table where rownum < 7267563 is also giving result instantly...
    but the entire table is not getting result i.e. select * from table...also there is no lock in the table(though i know that select is nothing to do with lock)..
    what may be the issue..please suggest...thanks in advance...
    Edited by: user12780416 on Dec 12, 2011 11:08 PM

    Hi;
    Please see below thread
    query takes too long ...
    help in solving long run query
    HOW TO: Post a SQL statement tuning request - template posting
    Hope it helps
    Regard
    Helios

  • A simple list with seven time buckets starting from the date report is run.

    Hi All,
    I am new to ABAP.Recently i have planned to write a progam which will help in planning the delivery of scheduled items.For a given sales Org. it will display all the undelivered,delivered items in a simple list and sort them with delivery dates.it will also provide a summary report at material group.For that i have used selection screen(LIKP-VKORG-Obligatory).when i enter VKORG Details i should get all the delivery docs for which delivery is not done or partially done.For this i have taken one more table LIPS
    (LIPS-MATKL,LIPS-MATNR,LIPS-VBELN,LIPS-POSNR,LIPS-WERKS,LIPS-LFIMG,LIPS-MEINS) for tables LIKP and LIPS VBELN is the key field.when i enter VKORG Data in the selection screen ,how can i get the data from LIPS Table.Please explain?
    Also report should be simple list with seven time buckets starting from the date when the report is run.The amount of quantity to be delivered should be displayed under appropriate bucket i.e within the bucket where its delivery date falls in.for ex:If the report is run on Tuesday 15th march 2010 then the start date 1 should be starting date of the week which is Monday 14th March.
    The report will be summarized at Material Group and Material Number.
    Appreciate your help
    Thanks and Regards,
    Shakeer Hussain

    Sorry, sounds too much like a complete requirement you want done for you by the community.
    Please work on it yourself and search for available information before posting specific problems only.
    Thread locked.
    Thomas

  • Simple Select Query Taking 5-10s

    We have a web server on the same lan as the DB server.
    A simple select * from tablename (~100 entries) is taking
    anywhere from 30ms to 10 seconds lan. ASP code on the web server
    provides instant (30ms) queries. Ping is never <1ms. If I point
    to a remote DB server, the same query is never more than 300ms
    (which is great for over the internet).
    I enabled logging in CFAdmin -> Datasources and shortly
    after my select * from tablename I see this:
    spy(2009/02/28 16:39:00.539)>>
    Connection[2].setReadOnly(boolean readOnly)
    spy(2009/02/28 16:39:00.539)>> readOnly = false
    spy(2009/02/28 16:39:00.539)>> OK
    spy(2009/02/28 16:39:05.726)>> OK (true)
    We need to get this up and running ASAP. Please help!!

    > I'm connecting to SQL Server 2000 on a Win2k3 box.
    > The default CF8 Installation.
    > Every table this happens for.
    OK. I think CF8 runs the most recent JDBC drivers too. It
    might pay to
    check that though.
    > Select * is needed, because we have existing sites we
    are migrating a lot of
    > which use select *.
    Sure. But just for the purposes of experimentation, change
    your test code
    to specify columns to see if it makes any difference.
    It might pay to get hold of FusionReactor to check what CF is
    doing with
    the queries, under the hood.
    Adam

  • Selecting with a special character

    Hi,
    I have a table in which an user can query via a sql prompt (accept) for a text he wants to search for. This search string can contain special characters like @,$,& etc but nog on a specific position. Sometimes they search for bbbb.hhhh_23, the next time the search for pppp & xxxx. I already thought that (double) quoting would help, tried escaping (\) also but still got errors with my procedure. So, how can I search those tables with the special chars and display the text the user is searching for?
    Thanks!
    Paul

    Hi,
    Please see the forum FAQ {message:id=9360002}
    What exactly is the problem you're having?
    What input are you giving, and what output are you expecting? Remember, you need to post something that the poeple who want to help you can run to re-create the problem and test their ideas. In this case, you need to post something like this:
    "I'm running this in schema ATL5_TEST, which includes this table: CREATE TABLE TABLE_X ... with these rows: INSERT INTO table_x ....
    When I run the script and set &search to 'A_B', I'm expecting these results ... because ... but instead, I'm getting these results ... As you can see, the results are missing ....
    When I run the script and set &search to 'C%D', I'm expecting ... because ... but instead, I get this error message: ..."
    Simplify the script as much as possible. For example, if the problem involves how to accept a certain character into a substitution variable, then you don't need to post 60 lines of PL/SQL code, even if your goal is to use that substitution vaiable in that PL/SQL code. Just post the ACCEPT statement, maybe a very simple "SELECT ... FROM dual;" query to get some results, a couple of inputs, and the expected outputs/
    Never write, let alone post, unformatted code. Indent the code to show the scope of BEGIN, IF, LOOP, and so on.
    When posting any formatted text (including, but not limited to, code) on this site, type these 6 characters:
    \(all small letters, inside curly brackets) before and after each section of formatted text, to preserve spacing.
    The EXCEPTION section you're using is only hiding details about the error.  Get rid of it.
    Whenever you write dynamic SQL, start by displaying the SQL string *instead of* executing it.  for exampledbms_output.put_line (v_sql || ' = v_sql before EXECUTE IMMEDIATE');
    -- execute immediate v_sql
    -- into v_match_count;
    When you get this much running, and the output is what you expect, then you can uncomment the EXECUTE IMMEDIATE statement.  Later, you'll want to comment out the call to put_line.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to run a simple program with main?

    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

    In SP2 we've made it very easy to automatically set the main class name
    when you first try to run a class in a Java project that doesn't have
    already have debugging configured.
    More generalized ways to easily run a class with a main method are
    already on the list for the next release.
    Thanks for the feedback,
    Josh
    Carl wrote:
    Thanks, that worked:)
    Workshop should consider dealing with simple classes with main much
    simpler...
    "Josh Eckels" <[email protected]> wrote in message
    news:3f96f8c1$[email protected]..
    Yes, you can run and debug it, but it needs to be in a Java project. If
    it's not already in one, create a new Java project and copy in the
    source. Go to the Project Properties, and select the Debugger settings.
    Enter the class that contains the main method. If you'd like, you can
    set the checkbox for Build before Debugging so that you are always
    running off the current source code.
    You should then be able to run the project after building it.
    Josh
    Carl wrote:
    I have a simple class with main, something like the following:
    public static void main(String[] args) {
    Is it possible to run / execute this main from within workshop?

  • Swap Counter in simple Selection Sort method

        void sortSelection(List object)
             int swapCount=0;
               for(int i = list.length; i >= 2; i--)
                 int maxIndex = 0;
                        for(int j = 1; j < i; j++)
                             if(list[j] > list[maxIndex])
                                  maxIndex = j;
                   int temp = list[maxIndex];        //
                   list[maxIndex] = list[i-1];         //         Is the problem here?        
                   list[i-1] = temp;                     //
                   swapCount++;                     //
              System.out.println("\n" +swapCount+ " swaps were needed. ");
        }This is a pretty simple selection sort method. But I am fairly sure that I am incorrectly counting swaps with the code. I have defined a "swap" as when two array indices have their values switched. I am convinced that there is something wrong because the array of numbers is randomly generated, and yet the swapCount counter is always equal
    to (list.length-1) when it prints out. I would think it should be different every time. I indicated the line where I believe the problem lies, but I am not for sure. Thanks everybody.

    List of Random Integers, then sorted:
    9, 29, 30, 42, 53, 58, 59, 64, 66, 69, 74, 79, 79, 87, 95
    9 swaps were needed.then sort again (descending) and get this:
    95, 87, 79, 79, 74, 69, 66, 64, 59, 58, 53, 42, 30, 29, 9
    1 swaps were needed.I'm pretty sure that isn't correct. But forgive me if I did not specify that it was to work in descending order as well.
    So I tried this:
    void sortSelection(List object)
             int swapCount=0;
               for(int i = list.length; i >= 2; i--)
                 int maxIndex = 0;
                        for(int j = 1; j < i; j++)
                             if(list[j] > list[maxIndex])
                                  maxIndex = j;
                  if (maxIndex != (i-1) && ascending==true)
                       int temp = list[maxIndex];
                        list[maxIndex] = list[i-1];                             
                        list[i-1] = temp;   
                        swapCount++;
                  else if (maxIndex != (i+1) && descending==true)
                       int temp = list[maxIndex];
                        list[maxIndex] = list[i-1];                             
                        list[i-1] = temp;   
                        swapCount++;
    } adding the i+1 (because it is going in a different order)...and I think I solved it!

  • [Q] simple page with calculations

    Hi everybody,
    i'm completly new to Oracle APEX and i tested some things with a very simple Applikation at first.
    I can view, edit, delete my data. I tested simple reporting with Diagrams. Everything is working fine.
    Now i thought about a simple Page with some Calculations. I want to select my Data through Comboboxes
    and then doing some simple calculations with a button press.
    Like..
    Selecting a Country -> showing me some values for that contry.. (sales, whatever) -> entering 5% in a textbox
    ->pressing calculate -> and its showing me the result on the screen
    Now I'm completly lost on "How to start"... Is this even possible? I dont want a complete walkthrough..
    Maybe someone can give me just a hint "How to start"..
    Greetings

    Consider placing a LOV to select Country codes and a Text item to capture your percentage within your Report region.
    Then your code would mimic this code where p1_letter would be your Text item and p1_state would be your LOV.
    SELECT a.state_name
      FROM demo_states a
    WHERE     a.state_name LIKE '%' || UPPER (:p1_letter) || '%'
           AND a.st LIKE '%' || UPPER (:p1_state) || '%'Jeff

  • Simple query with like return wrong result

    Hi,
    I run simple query with like.
    If I use parameter I get wrong results.
    If I use query without parameter results are ok.
    My script:
    ALTER SESSION SET NLS_SORT=BINARY_CI;
    ALTER SESSION SET NLS_COMP=LINGUISTIC;
    -- drop table abcd;
    create table abcd (col1 varchar2(10));
    INSERT INTO ABCD VALUES ('122222');
    insert into abcd values ('111222');
    SELECT * FROM ABCD WHERE COL1 LIKE :1; -- wrong result with value 12%
    COL1
    122222
    *111222*
    select * from abcd where col1 like '12%'; -- result ok
    COL1
    122222
    I use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    and query run in Oracle SQL Developer 3.1.07.

    Hi,
    welcome to the forum.
    When you put some code please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    You should specify exactly how you run your code.
    If I run this statement in SQL Plus:SQL> ALTER SESSION SET NLS_SORT=BINARY_CI;
    Session altered.
    SQL> ALTER SESSION SET NLS_COMP=LINGUISTIC;
    Session altered.
    SQL>
    SQL> -- drop table abcd;
    SQL> create table abcd (col1 varchar2(10));
    Table created.
    SQL>
    SQL> INSERT INTO ABCD VALUES ('122222');
    1 row created.
    SQL> insert into abcd values ('111222');
    1 row created.
    SQL>
    SQL> SELECT * FROM ABCD WHERE COL1 LIKE :1;
    SP2-0552: Bind variable "1" not declared.
    SQL>
    I got this error. So I wonder how you set value 12%
    Please specify exactly how you run your test as we cannot reproduce your problem.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • [bug report] Making selection with pen tool causes 'jittery' edge

    When I use the pen tool to create a path, and then make a selection from it and select inverse and delete the background, the result is a very un-even edge not the clean resullt you would expect, however if I make a mask from the same selection it looks fine.
    Steps to recreate
    1. Draw a simple path with the pen tool
    2. Make a selection from the path, with 0 feather and anti alias turned on
    3. Inverse selection (optional, same thing happens if you don't inverse)
    4. Delete the rest of the image
    5. The edge of the image now has an uneven, jittery edge
    compared to mask
    5. Undo the delete
    6. Go to Channel Pallette, and make a mask from the selection
    7. Edge of the mask should be clean like you would expect
    You can exaggerate the jittery effect by adding feather the the path selection

    Ok please Delete this I've sorted it. The blending mode had jumped to disolve.... but I 100% didn't change it to this myself, I wasn't even in the layer pallette at the time

  • Checkedlistbox allows multiple selections with Selection mode set to one

    I have a simple CheckedListBox with three options. I set Selection Mode to One. When I test the form, it allows me to have more than one box checked. I can clear the other two with a program, but my understanding of Selection Mode was that it would not
    allow more than one box to be checked if set on one.

    Option Strict On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    CheckedListBox1.SelectionMode = SelectionMode.One
    For i = 1 To 10
    CheckedListBox1.Items.Add("Number" & i.ToString)
    Next
    End Sub
    Private Sub CheckedListBox1_ItemCheckChanged(sender As Object, e As ItemCheckEventArgs) Handles CheckedListBox1.ItemCheck
    Dim ItemIndex As Integer = e.Index
    For i = 0 To CheckedListBox1.Items.Count - 1
    If i <> ItemIndex Then
    CheckedListBox1.SetItemCheckState(i, CheckState.Unchecked)
    End If
    Next
    End Sub
    End Class
    La vida loca

Maybe you are looking for

  • Mid 2010 Macbook Pro (7,1) - Downgrading from Mountain Lion (10.8.3) to Snow Leopard

    Hi everyone! I am looking for some help with downgrading my macbook pro from ML back down to SL. I'll start off with some information about my case: I bought this computer mid 2010 - I believe in July, if that matters. It is a Macbook Pro 7,1 model.

  • My app store is in German

    Hello, its going to be two days that my app store is allemand.Morevover, I received emails saying I'd buy an apllication in the German app store when it is not true. When I try to change the language, they tell me that my username is available for th

  • Space which isn't there prints in a word

    Some time back I produced a brochure for a friend in AW Draw. Some more copies are needed and I have changed from inkjet to laser printer (both Epson: Stylus C70 to Acculaser C2600). When I print one word now has a rogue space in it (word = 'large' w

  • OAM alerts setup for Concurrent services down using workflow mailer

    Hi, We have ORacle Ebiz 12.0.6 with 10.2.0.4 database. Can some one please provide details how to end notification email for Concurrent services down using OAM in R12 with workflow. I have done the setup in clone with workflow up and running... and h

  • Why won't firefox 3.6 accept backed up profile.

    I followed suggested guidelines for creating a new profile from a previously backed up profile in a new install of 3.6. Firefox either doesn't accept the profile, (e.g. I get a new profile, startup screen, no bookmarks, etc), or I get an "already run