SQL query: How to match multiple names strictly with its appropriate values

Hi all

Assume there is a table of CODES (with 3 columns) as follows:...
------------------------------------------------
Name ID value
------------------------------------------------
SFO 100 080
200 NY 044
300. THE 040
------------------------------------------------

I would need to write a SQL to retrieve the rows that match few of names and values. For example: (1) name = "NY" and value = '044' and (2) name = "LA" and value = "040".

I wrote this sql...
SELECT id, name, value of CODES whose name IN ('NY', THE ') and the value IN ('044 ', ' 040')
This returns 2 rows as expected.

At the same time, even for the following query, the same 2 rows are returned (which is false)
SELECT id, name, value of CODES whose name in ('NY', THE ') and value in ('044 ', ' 444')
-See the code std 444.

My requirement is that the above query should return to the line for NY.

My question is: how to match multiple names strictly with its appropriate values... ? That is to say, unless '040' is specified in the part 'value', the corresponding line in 'LA' should not be returned...

I feel, nor the case AND neither the case of GOLD can be used in Where clause to check these 4 values.

Any ideas... ? Can you please let me know... ?

Thank you
REDA

as:

select id, name, value from CODES where (name, value) in (('NY', '044'), ('LA', '040'))

Published by: Lacotte Renaud on February 16, 2010 10:35

Tags: Database

Similar Questions

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • How can I return my screen to its default values after you run the Windows 7 color calibration?

    I decided to run the color calibration tool windows to try to optimize my monitor, but the quality came out worse than before. After trying several times and otherwise, to get a better picture I decided that I would just back to its default value. The problem is that I don't see an option for it. So, how can I reset my screen its initial values of before I tried calibration it?

    Thank you

    Using Windows 7 Pro 64-bit

    Windows (rstrui.exe) system restore would do it without data loss.

  • InDesign: how to move a rectangle object with its content?

    Hello

    I'm developing an indesign extension with flash builder and extension builder cs 2.

    When I move a rectangle object that contains an image whose ownership geometricBounds image does not move and is no longer visible...

    How to move a rectangle with its content?

    Thank you

    Simon

    Use rectangle.move)

  • SQL query: How to list the values in the IN operator

    Hello

    I'm going through a list of values to the location of < > in < list >
    I don't want to use dynamic cursors (REF CURSOR). Is this possible using Oracle SQL?
    Please let me know.

    My program:

    DECLARE
    ...
    list_of_ids: = '10, 20, 30';
    ...
    SELECT MAX (sal) IN the max_sal FROM Employees WHERE emp_id IN (list_of_ids);
    ...
    END;
    /

    Thanks in advance,
    Niko

    You do not want a list separated by commas. You want to move a collection. Then

    CREATE TYPE num_tbl
    AS
    TABLE OF NUMBER;
    
    DECLARE
      l_list_of_ids num_tbl := num_tbl( 10, 20, 30 );
    BEGIN
      ...
      SELECT max(sal)
        INTO max_sal
        FROM employee
       WHERE emp_id IN (SELECT * FROM TABLE( l_list_of_ids ));
      ...
    END;
    /
    

    Justin

  • How to create multiple Sources/Classes with a Script

    I'm trying all my java sources or classes, enter a script so that I can pass them all to another server without having to compile each file individually. When I concatenate two files and you try to compile I get an ORA-29536: badly formed source error.

    How can I get multiple definitions into a single file and compile all classes?

    Thank you

    Gregory

    Gregory:
    If you want to download several Java classes in a manuscript of the solution is .sql file, for example:
    ---------------------------------------------------------------------------------------------------------------------
    definition of set?

    create or replace and compile the java source named 'my. Sleep' as
    package my;
    java.lang.Thread import;
    public class {sleep
    Public Shared Sub main (String [] args) survey java.lang.InterruptedException {}
    If (args! = null & args.length > 0) {}
    s int = Integer.parseInt(args[0]);
    Thread.Sleep(s*1000);
    } else
    Thread.Sleep (1000);
    }
    }
    /

    create or replace and compile the java source named 'my. Did app»
    package my;
    public class App {}
    Public Shared Sub main (String [] args) survey java.lang.InterruptedException {}
    System.out.println(args[0]);
    }
    }
    /

    output
    ---------------------------------------------------------------------------------------------------------------------
    Then the .sql file can be analyzed using the tools SQLDeveloper, JDeveloper, or SQLPlus.
    HTH, Marcelo.

  • SQL Query to retrieve data in XML format with several levels

    Hello

    I'm looking to help generate XML from Oracle database. The request must contain many levels of sub...

    For example.
    Create table inventory
    (Group varchar2 (10))
    category varchar2 (10),
    ProductName varchar2 (10),
    Detail varchar2 (10));

    The output should be also present below. The data must be multiple values for each item.

    < inventory >
    < name of group 'auto' = >
    < category name 'cars' = >
    < name productname = 'Seat' >
    < details > red color < / details >
    < details > 5 seats < / details >
    < / productname >
    < / category >
    < / Group >
    < / inventory >

    Please share your ideas by retrieving data in the XML structure using SQL or PL/SQL for oracle 10 g.

    Thank you and best regards,
    Siva.

    This?

    SQL> create table t as
    with t as (
     select 'automobiles' "GROUP", 'cars' category, 'seat' productname, 'color red' details from dual union all
     select 'automobiles', 'cars', 'seat', '5 seats' from dual union all
     select 'automobiles', 'cars', 'make', 'ford' from dual union all
     select 'automobiles', 'cars', 'make', 'Toyota' from dual union all
     select 'automobiles', 'Bus', 'Model', 'volvo' from dual union all
     select 'automobiles', 'flight', 'Airbus', '400 passenger' from dual union all
     select 'automobiles', 'flight', 'Airbus', '500 mph' from dual union all
     select 'HealthCare', 'Nutrition', 'centrum', 'Organic' from dual union all
     select 'HealthCare', 'Nutrition', 'centrum', 'Chemical' from dual union all
     select 'Computers', 'Software', 'Database', 'Oracle' from dual union all
     select 'Computers', 'Software', 'Database', 'sqlserver' from dual
    )
    select * from t
    /
    Createtable successfully completed.
    
    SQL> select xmlserialize (content x.column_value indent) xml
      from xmltable('element Inventory
                     {for $g in distinct-values(ora:view("t")/ROW/GROUP)
                       return element group
                          {attribute name {$g},
                            for $c in distinct-values(ora:view("t")/ROW[GROUP=$g]/CATEGORY)
                              return element category {attribute name {$c},
                                for $p in distinct-values(ora:view("t")/ROW[GROUP=$g and CATEGORY=$c]/PRODUCTNAME)
                                  return element productname {attribute name {$p},
                                    for $d in distinct-values(ora:view("t")/ROW[GROUP=$g and CATEGORY=$c and PRODUCTNAME=$p]/DETAILS)
                                      return element details {$d}
                                                             }
                                                      }
                          }
                     }') x
    /
    XML
    --------------------------------------------------------------------------------
    
      
        
          
            
    Oracle
    sqlserver
    Chemical
    Organic
    volvo
    Toyota
    ford
    5 seats
    color red
    400 passenger
    500 mph
    1 row selected.
  • How to specify multiple DNS servers with Dr.-ip-customizer

    Hey guys,.

    The CSV file I get out of the Dr.-ip-customizer tool seems to imply that I can specify multiple DNS servers (it has a column called "DNS Server (s)'").  My problem is that I do not know how...  I tried to put in two server IPs with a space between them, I also tried a comma followed by a semicolon.  The semicolon and space gets the error thrown upward when I try to import that says 'Invalid DNS server field' and the comma causes her think that there are too many columns (since it is after all a CSV file).

    so, any ideas? What I have to put on separate lines or something

    According to the Administrator's guide (P. 56, it is not very clear), it seems that you want to place the second DNS server on a new line with the VM ID and the number of the adapter.  '0' If you want to be global value or the number of actual card to override the global settings.

    Hope that helps...

    -alex

  • How to match operating system installed with licenses Correct software

    I have three laptops and two desktops. Microsoft Office is loaded on each computer.  I have licenses for all machines.  My problem is I don't know what license accompanies each machine and I am doing a gift of two of the machines and want to include the correct software license.  I have the same problem with two operating systems, both professional XP.

    Is it possible for me to "look in" each machine and identify the correct license?

    I appreciate all help.

    If you have the installation media, that is, a way to reinstall Windows and Microsoft Office, I suggest that you wipe the hard drives using Darik Boot and Nuke (http://dban.org/). There is a link "help" at the bottom of DBAN.

    If Windows came pre-installed on all computers, you can use whatever mechanism has been provided by the manufacturer to return the computer to its "fresh coming from the factory" State.  If Microsoft Office was also preinstalled, you will have to install them separately.

    If you do not have something like the above, you run the risk of any personal information on the computer being recovered by one that ends with the machine by hand.

    If you want to know the license keys of software installed on a computer, download and run Belarc Advisor--> http://www.belarc.com/free_download.html or of Jellybean Keyfinder magic--> https://www.magicaljellybean.com/keyfinder/

    (Yes, it works for XP even if the main web page says Windows 7 and 8).

    Belarc will produce a detailed report of the hardware and the software on the computer.  Of Magical Jellybean KeyFinder is a much more limited tool, but will still provide for Windows and Office product keys.

    For Windows pre-installed, however, the product key that is returned by one of these tools is one used by the manufacturer at the factory.  If Windows has to be reinstalled using a CD which is the same version as the pre-installed version (e.g., XP Edition family), the product key that should be used is on the sticker affixed to the computer COST.

    For some versions of Windows non-detaillants tools will return a fake license key.  The following example comes from a facility of the license Volume (VLK) key.

    Microsoft - Windows 7 Professional (x 64)

    55041-033-3500355-86417 (key: BATH-BATH-BATH-BATH-BATH)

  • SQL Query to retrieve records in a table with the same records or only one record in a table

    Hello

    Got a curious requirment to extract the Non-distincts records in a table

    Example of

    Account number Type of account
    12345SB
    12345

    SB

    12346CR
    12346SB
    12347SB
    12348CR
    12349SB

    Requrirement is to retrieve the records as follows

    Result must be

    Account number Type of account
    12345SB
    12345

    SB

    12347SB
    12348CR
    12349SB

    You will notice that 12346 which has two separate lines have been eliminated in the result. I tried several qeries to achieve this result, one or the other had a few mismatch. Can someone give me a request for it.

    Thanks in advance.

    SELECT ACCOUNT_NUMBER,

    ACCOUNT_TYPE

    DE)

    SELECT ACCOUNT_NUMBER,

    ACCOUNT_TYPE,

    COUNT (*) ON CNT_ACC (ACCOUNT_NUMBER PARTITION).

    COUNT (*) ON CNT_NUM_TYP (PARTITION ACCOUNT_NUMBER, ACCOUNT_TYPE)

    FROM T1)

    WHERE CNT_ACC = CNT_NUM_TYP;

    exit;

    12345 SB
    12345 SB
    12347 SB
    12348 CR
    12349 SB
  • How to run multiple simultaneous backups with VDR 1.2

    I have several VDR 1.2 devices, using every two CIFS shares for data warehouses.  I did not any changes in the .ini on devices file (the file does exist), but I am only able to write a backup at a time.  If I try to run a job manually all-in-one runs, it fails with a message telling me to look under "Reports" error messages.  However, there is nothing there.  I also can not save/restore the integrity checks are running.  It was also a problem of point 1.1, but it would actually give an error message that they data store was busy.

    I tried to import a whole new camera VDR and by attaching it to a new data store - same result.

    Does anyone have an idea what might happen?

    Thank you.

    Allen Beddingfield

    Systems engineer

    The University of Alabama

    Yes, exactly. We first had a VDR with 12 GB of RAM and 4 vCPUs and were not able to run several jobs once. Now, we decided to create two VDR each 4 GB RAM Max. Now, everything works!

    See you soon

    Nils

  • How to check the option buttons with button Differfent values

    Nice day

    I am currently trying to write a script that would mask 5 6 radio buttons

    I have an option called "" 3 button "Transferr.

    with values of:

    Yes;

    Supp;

    Reg; and

    do_not_transfer

    so, I have a menu drop down called ""Rel. ARTICLE".

    with values of

    3A;

    3 (B);

    4 (A);

    4 (B); and

    4 C

    I know how to get the value of the box and manipulate the other fields

    as

    BEGINNING

    transfer of var = getField ("3. Transfer") .value

    var relitem = getField ("rel. HEADING") .value

    If (transfer = "Yes" | = "Extra" transfer) & & (relitem == '4 c' | relitem == "4 (B)" ""))

    {

    getField ("a. recommend").checkThisBox(0,true);
    getField("a._recommend").display = display.visible
    getField ("a. I didn't recommend").checkThisBox(0,false);

    getField ("a. I do not recommend") .display = display.hidden

    }

    ElseIf (transfer = "do_not_transfer")

    {

    getField ("a. recommend").checkThisBox(0,false);
    getField("a._recommend").display = display.hidden
    getField ("a. I didn't recommend").checkThisBox(0,ftrue);

    getField ("a. I do not recommend") .display = display.visible

    }

    END

    I would like to make sure that rel. ARTICLE! = 4 (A); 4 (B); 4 (c) with values of 'Yes', it is the "Extra" box and "Reg" are hidden, while "do_not_transfer" is still displayed and checked.

    I was passing through forums, google and acrobat documentation and I can't seem to find what I'm looking for.

    Thank you for your help in advance.

    if (transfer = "Yes" || transfer = "Supp") && (relitem == "4(C)" || relitem == "4(B)"))
    

    This should be:

    if ((transfer == "Yes" || transfer == "Supp") && (relitem == "4(C)" || relitem == "4(B)"))
    

    Similarly,.

    else if (transfer = "do_not_transfer")
    

    must be:

    else if (transfer == "do_not_transfer")
    

    In order to work with an individual widgets in a form field, get an object that represents the widget using the getField method specifically demonstrated in example #2 in the documentation: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.476.html

  • How the hell this guy fired with its extruded 3d pencil?

    In the following video, Mr. Smith a first extrude text. Then, about 40 seconds, he takes his pencil and draw a line and it is automatically expelled. How the hell did do that? Looks like it is expelled as soon as it leaves his click. Am I just missing it does 'shift-control-e' to apply the same 3d effect immediately to his line? Of course it looks that he was not obligated to do that... I see in the appearance Panel, that there is "no selection", but this 3d extrusion effect is shown here.

    http://www.Adobe.com/DesignCenter/video_workshop/?ID=vid0053

    If you create an effect that you can keep this effect to the newly created art making in this new Art has basic appearance is deselected in the appearance Panel. Now, make an impact to a certain type, now draw a line. If you have this deselected in the context menu of the line appearance Panel should have the same effect as the type.

  • How to create a new record with the old values

    Hi all

    I have the creation with 45 page are there fields
    the user will enter all areas and save, it will call the uneditable mode

    If the change button is clicked it will call for the editable mode

    My requirement is user will not change among these ites (45 items) clcik on save again it will call to view mode

    in this user will change one value among 45 Articles and click on the button Save I need to create more than one record in the database

    If the user will not modify one of the field elements of the 45 I will not create a new record in the database

    How can we achieve this feature


    Concerning
    Anthony

    Hi Mary,

    Please try this method to copy a line in the new line...

    public void copy()
    {
    Pervert SuppliersVOImpl = getSuppliersVO1();
    Rank rank [] = pervo.getFilteredRows ("SelectFlag", "Y");
    for (int i = 0; i)<>
    {
    Rowi rank (SuppliersVORowImpl)= SuppliersVORowImpl;
    OADBTransaction trx (OADBTransaction) = getTransaction ();
    Number b = trx.getSequenceValue ("FWK_TBX_SUPPLIERS_S");
    AttributeList a rowi = (AttributeList);
    R = (SuppliersVORowImpl) pervo.createAndInitRow SuppliersVORowImpl (a);
    Define your unique attribute values here, I'll put here Ref supplier as with each new line, it must be different.
    r.setSupplierId (b);
    pervo.insertRow (r);
    }
    }

    Kind regards
    Out Sharma

  • Œuvres SQL query to MS SQL Server 2008, but not when you use the database kit

    I have this SQL query:

    DECLARE TABLE (@DataTypeTable)
    Name varchar (128).
    TypeID INT)

    -Add comma delimeted type data in the temporary table names
    INSERT INTO @DataTypeTable (name)
    SELECT * from WhatWeShouldDoRead.func_Split (@DataTypeTrimmed, ',')

    SELECT the name OF @DataTypeTable

    That takes a comma delimited by the string and returns the string as a table.  It works correctly in Microsoft SQL Server Management Studio.  When I run this as a stored procedure I return nothing.  There are no errors, SQL or otherwise.  I checked that I am connected to the correct database and the stored procedure is responsible without changing any error chain which is reported of this stored procedure (that code is not shown in the example above).  Has anyone seen this problem before, or have experience with SQL/Labview interfaces to tell me what I am doing wrong?

    Thanks in advance.


Maybe you are looking for

  • macOS Sierra - calendar Agent Crash

    I installed macOS Sierra on my MBP 8.3 (17 "end 2011) - 16 GB of RAM. 1 TB SSD. After you have identified a problem with a Logitech mouse driver (and delete) I stopped for a few days to attend to other things. Restart today, I had a few problems: 1.

  • signature of a pdf document

    I just upgraded to OS X 10.11.5 and use Adobe Reader 10.1.4. I would like to add a signature to a PDF document that I opened. The signature is already created in the preview and I can't find the image it under Tools > annotate > Signature. Adobe requ

  • Satellite Pro L50 - A disconnects from the WiFi every 20 minutes approximately

    I searched around on the internet for advice. I downloaded the latest drivers from toshibas website, I put my power maximum output on Device Manager, and it is not my ISP, as happens at any hotspot wi - fi including familys homes, work, etc.. Please,

  • Satellite L20 keyboard & touchpad work not but keyboard works in the BIOS

    On my laptop Satellite L20 not work keyboard and the touchpad and keyboard works in the BIOS, USB ports also does not (USB mouse). Can I get the BIOS update file (traditional update on the boot CD, no BONE!) Sorry for my bad English.

  • Research and correspondence - difference between 'Match' and 'geometric model Match "?

    I was wondering if someone can explain to me the difference between 'Pattern Match' and 'Geometric pattern Match' screws? I don't really know how best to use for my application. I'm search/match small spherical particles in a video gray in order to f