between the operator for VARCHAR values

Hello

I'm trying to compare a value varchar between two varchar values that does not work.

for example in my table there are two columns.

FROMpcode (column1)
*****************
L6P 0 TO 1
L6A 0 TO 1

TOpcode (column2)
****************
L7E 5 S 1
L6A 4R1


the value I want to compare for between FROMpcode and TOpcode is L6S 6B 7. This is the query. This is comparison of Canadian postal code.

Select * from mytablename where L6S 6B 7 between FROMpcode and TOpcode

I can't convert FROMpcode, TOpcode in numbers because they are alphanumeric data.

Thanks for your help.

Techie_nas

Hello

[email protected] wrote:
This is the create table script.

CREATE TABLE APPS.MYTABLENAME
(
FROM_POSTALCODE  VARCHAR2(7 BYTE),
TO_POSTALCODE    VARCHAR2(7 BYTE)
)

and here is the sql insert code.

insert into mytablename values('L0N 1A0','L7K 2P9');
insert into mytablename values('L0N 1B0','L7K 1E3');
insert into mytablename values('L6P 0A1','L7E 5S1');
insert into mytablename values('L0N 1E0','L7K 2N5');
insert into mytablename values('L0N 1C0','L7K 3L3');
insert into mytablename values('L0P 1C0','L7C 3M3');
insert into mytablename values('L0N 1K0','L7C 3M1');
insert into mytablename values('L0N 1P0','L7K 0H5');
insert into mytablename values('L0P 1N0','L7K 1N6');

and when I run the sql code

select * from mytablename where 'L6S 6B7' between from_postalcode   and to_postalcode

instead of only from the third row, I see all 9 lines in the results.

Why you should see only the third row? 'L6S 6B 7' is really between from_postalcode and to_postalcode of the 9 rows. Take the first row, for example:

insert into mytablename values('L0N 1A0','L7K 2P9');

'L6S 6B 7' comes after "L0N 1 to 0" in the sort order, because "L6" comes after "L0".
"L6S 6B 7" comes before "L7K 2 p 9' sort order, because"L6"comes before"L7"."

Maybe you don't really want the BETWEEN operator at all.
Explain why you want the third line and not all the others and someone will help you code.

Tags: Database

Similar Questions

  • What is the differene between the operation of the filter and NL semi join?

    Hi all.

    The oracle is gr 10, 2 and 11 GR 2.

    There are differences between the operation of the filter and the HASH/MERGE semi join in the treatment of subqueries.

    But I couldn't see the difference between the operation of the filter and NL semi join?
    (the only thing I know is that the operation of the filter mechanism has cached, but I'm not sure if semi NL)

    What are the advantages and disadvantages of each of them?

    Thanks in advance.
    Best regards.

    >
    The oracle is gr 10, 2 and 11 GR 2.
    >
    These are not "version. What are the 4-digit versions?
    >
    There are differences between the operation of the filter and the HASH/MERGE semi join in the treatment of subqueries.
    >
    What is? When you make a statement like this post the information (and links) that backs up your statement.
    >
    But I couldn't see the difference between the operation of the filter and NL semi join?
    (the only thing I know is that the operation of the filter mechanism has cached, but I'm not sure if semi NL)
    >
    We cannot 'see the difference' you don't has not post anything to watch us.
    >
    What are the advantages and disadvantages of each of them?
    >
    Each of what? Again - it must be as specific as possible if you want specific comments.

    In addition, given that you should generally not use indications in production in any case code what does what are the differences? Oracle will make the choice.

    Without something specific to comment on everything that we can do is provide several links that talk about joins and how to produce and review them. These are all notebook of Jonathan Lewis:

    http://jonathanlewis.WordPress.com/?s=semi-join
    http://jonathanlewis.WordPress.com/2010/12/20/index-join-4/
    http://jonathanlewis.WordPress.com/2010/08/15/joins-MJ/--Les merge joins
    http://jonathanlewis.WordPress.com/2010/08/10/joins-HJ/--Les hash joins
    nested loops http://jonathanlewis.WordPress.com/2010/08/09/joins-NLJ/--joings
    http://jonathanlewis.WordPress.com/2011/06/08/how-to-hint-1/--comment tip for joins

    Check out these articles. Pay attention to how, in each of them, it does not provide only a text description but also provides the code and explains the code.

    In other words, it provides information specific to illustrate what he is talking about. That's what you need to do if you need help with a specific topic: provide the query plans and output that you use as the basis for your question. Allows us to see EXACTLY what you're talking about.

  • How to use as operator for several values

    Hi all

    I want to obtain the column values for the column - filed_name which ends by ('X 1', 'X 2' 'X 3' 'X 4' 'X 5' 'X 0' 'XA' 'XB' "XM" "XP" 'X' "CM" "MT") of the variable_info table


    I tried to use as shown below

    SELECT * FROM VARIABLE_INFO WHERE FieldName like (' %x 1 "," %X 0 ");

    but getting error
    ORA-00907: lack of right parenthesis

    can someone tell me how to use as operator for multiple values?

    Thank you/kumar

    You need not a subquery, just make sure that you use parentheses to group your GOLD requirements

    SELECT RELATION ,
    FIELD_NAME ,
    ATTRIBUTE ,
    FIELD_DESCRIPTION,
    SOURCE
    FROM VARIABLE_INFO
    WHERE RELATION NOT IN ( 'CHAI',  'ITAB', 'ITB2', 'ITB3', 'MINI', 'NOTE', 'MINC', 'FINI', 'FTIM', 'FWTG', 'FMLY', 'FMIS', 'FSUM', 'MEMB' ,'FINC', 'FASO')
    AND (SUBSTR(FIELD_NAME,-2) in ('X1', 'X2' ,'X3', 'X4', 'X5', 'X0', 'XA', 'XB', 'XM' ,'XP' ,'CM','MT')
      OR substr(FIELD_NAME,-1) in ('X')
      OR substr(FIELD_NAME,1) in ('J')
      )
    AND (ATTRIBUTE LIKE 'NUM%' OR ATTRIBUTE = '-') ;
    

    The error you are getting sounds like a problem with the definition of VARIABLE_INFO. It seems the synonym or something that it points to rear edge

    For example:

    CREATE SYNONYM X FOR DUAL;
    CREATE SYNONYM Y FOR X;
    CREATE OR REPLACE SYNONYM X FOR Y;
    SELECT * FROM Y;
    
    SQL Error: ORA-01775: looping chain of synonyms
    

    Kind regards
    Bob

  • difference between the operational status of APs to the TOP and REG (registered)

    Hello guys,.

    I want to know what is the difference between the operational status of APs to the TOP and REG?

    Thanks in advance

    A radio operating state is up/down.  REG AP means that the PA has joined with success the controller.  The AP must be in the State REG (registry) radios appear.

    -Scott

    Please evaluate the useful messages *.

  • Difference between the operator NOT EXISTS and NOT IN

    Hi experts,

    I understand that this question has been asked several times, but I would like to have a clear understanding of the following:

    SELECT MEANING FROM FND_LOOKUPS WHERE LOOKUP_TYPE='WIS_WORK_DEFINITION_NAME';
    

    The results are:

    Spare

    Main working definition

    Rework

    Test

    User_Defined_WD

    Check

    I have run this query:

    select work_definition_name from  WIS_WORK_DEFINITIONS WSD WHERE WSD.ORGANIZATION_ID=207 AND WSD.INVENTORY_ITEM_ID=2686;;

    The query gives output below:

    MAIN

    REWORK

    When I run the sub query, I expect no result because the inner query in the NOT IN operator returns a NULL value.

    Query -1: the query is:

    SELECT fl.meaning FROM fnd_lookups fl WHERE fl.lookup_type='WIS_WORK_DEFINITION_NAME' AND fl.lookup_code NOT in
    (SELECT NULL FROM wis_work_Definitions wsd WHERE wsd.organization_id=207 AND wsd.inventory_item_id=2686
    AND  fl.lookup_code=wsd.work_Definition_name);
    

    If the inner query returns null, the query gives the result:

    Spare

    Test

    User_Defined_WD

    Check

    I was under the assumption that if the inner query returns null, then the global query would return no data. Example:

    Query-2:

    SELECT fl.meaning fl fnd_lookups WHERE fl.lookup_type = 'WIS_WORK_DEFINITION_NAME' fl.lookup_code AND NOT IN (SELECT NULL FROM dual);

    The query above pulled out no data as the inner query returned NULL. What I failed to understand was the difference between the query-1 and query-2.

    While Query1 returns data, query-2 not return all the data.

    There is no apparent difference between these two queries, because of the last sentence of your NOT IN query:

    AND fl.lookup_code = wsd.work_Definition_name

    Consider the row where lookup_code = HAND. The NOT IN query is a single line in wis_work_definitions where wsd.organization_id = 207 AND wsd.inventory_item_id = 2686 AND 'MAIN' = wsd.work_Definition_name. If your queries are actually like that for this line:

    SELECT fl.meaning fl fnd_lookups WHERE fl.lookup_type = 'WIS_WORK_DEFINITION_NAME' AND fl.lookup_code = 'MAIN' fl.lookup_code AND NOT in ('HAND')

    SELECT fl.meaning fl fnd_lookups WHERE fl.lookup_type = 'WIS_WORK_DEFINITION_NAME' AND fl.lookup_code = 'MAIN' fl.lookup_code AND NOT in (NULL)

    No one who will return a line, for reasons that are obvious, hopefully.

    Now consider the row where lookup_code = TEST. The NOT IN query finds a no line in wis_work_definitions where wsd.organization_id = 207 AND wsd.inventory_item_id = 2686 AND 'TEST' = wsd.work_Definition_name. A list NOT IN containing no words can be ignored, so the two queries become like this:

    SELECT fl.meaning fl fnd_lookups WHERE fl.lookup_type = 'WIS_WORK_DEFINITION_NAME' AND fl.lookup_code = 'TEST'

    Which returns a line.

    So the effect of these two queries is to return all values except those that appear in that particular (set of) definition (s) of work.

  • What is the difference between the Firefox for android and Firefox beta

    I noticed in the store of Google play there are two applications of Firefox. What is the center of the difference between the two Firefox browser for android and Firefox beta.

    Firefox for android is just the regular and stable browser that is recommended. Beta of Firefox for android is the next version of firefox that is in beta (test yet, but almost ready) step and is not ready for an official release because he has a few folds and fixes to do. But firefox for android beta has some of the features the most recent Firefox should be released soon as an official version.

    The current version of firefox for android is 34.01.
    The current version of firefox for android beta is 35.0.

  • Customize the operator for the SQL command

    With JDeveloper 12.1.3, I created a search form "Panel with ADF Query Table".  After having specified the search parameters, the SQL that is subject to the MSSQL root command generates the following error message:

    < oracle.adf.controller > < Utils > < buildFacesMessage > < ADF: addition of the following JSF error: incorrect syntax [FMWGEN] [SQLServer JDBC Driver] [SQL Server] close to ' |'. >

    java.sql.SQLException: incorrect syntax [FMWGEN] [SQLServer JDBC Driver] [SQL Server] close to ' |'.

    Here is the part of SQL code that is the question:

    WHERE (((city AS (?) || '%')) AND (State AS (?) || '%') ) ) ) )

    Since MSSQL does not accept the "|" as an operator is valid, an error message is generated.  MSSQL expects the CONCAT function or operator ' + '.  Is it possible and easy to configure JDeveloper for change the operator of ' | ' to the CONCAT function?

    OK, your settings are looking as it should.

    You have two options to work around the problem.

    (1) use your own sql generator, as shown here http://www.jobinesh.com/2013/02/customizing-sql-builder-class.html

    (2) modify the sql code generated for the START WITH operator generate the right sql for sql server code. For this, you can override the method getViewCriteriaItem() as shown here https://tompeez.wordpress.com/2011/08/21/extending-viewcriteria-to-use-sql-contains-4/

    Timo

  • The operation for the entity 'DeployTemplate' failed with the following message: "Cannot complete the customization."

    I am running my VMmark with the agent 6.0 update vCSA 2.  Most of the awnsers I found to this problem are the Windows version of vcenter.  It looks to its find the deploy.cab file, but for some reason any fails to complete customization.  Any help would be apperciated.

    I have attacahed my results file.

    Please try to see if you can manually deploy your model.  Here are the steps:

    1. The vsphere Web Client, right-click on your deployment model.
    2. Select "new virtual machine of this model.
    3. In the name box, enter "DeployVM0".
    4. Select the correct location of the DC, and then click Next.
    5. Select your cluster, and then click Next.
    6. Select your LUNS and click Next.
    7. Click on the box "Power on a virtual machine after creation" so that it is enabled.
    8. Check the box "Customize the operating system", and then click Next.
    9. Select the "StandbyCust" specification, and then click Next.
    10. Click Finish.

    Watch the deployment and customization of vSphere Web Client. You should be able to see the power of the virtual machine and customize from the console without logging in. Wait about 5 minutes to see if all the cloning and the specification of the OS process completed.  Then without logging in the newly created DeployVM, from the first client, at a command prompt, type the following.

    Ping ping STAF DeployVM0

    The correct answer is PONG.

  • Could not get the operation for SCC_PERSON_SYNC definition

    Hi all

    I get this error when trying to load data of candidates using EXCEL to CI.
    The full error message is as

    Unable to get the definition of operation for SCC_PERSON_SYNC. SCC_CONSTITUENT_MGR (2 928). UTIL. Name: PersonSAPublication of PersonSAPublication.OnExecute PCPC:55 statement: 2
    Called from: SCC_PERSON_SOA_CONSUMER. PersonServiceConsumer.SCC_PersBioConsumer.OnExecute name: setData statement: 155
    Called from: ADM_APPL_ENTRY1. GBL. SavePostChange statement: 3

    Can anyone solution.

    Kind regards

    You access the operation and verify its existence? PeopleTools > Integration Broker > Configuration of integration > Service operations
    Search SCC_PERSON_SYNC - ensure that its there and ensure that his license.

  • How to avoid the report for all values of roller running upward of guided navigation

    Hello

    Thanks in advance

    I have 3 reports on three different pages of a dashboard. (Set up a navigation guided on a column of each report). When I click on the value of the column of guided navigation lead me to report 2 for this particular value (is invited), similarly for 3 report also so far it works great.

    However when I go back to report 3 2 and 2-1, the reports are run for all the values for the value which has been adopted by the guided navigation of the previous report (on which I clicked to go to the next report of value) instead.

    Published by: 808623 on November 9, 2010 02:10

    Use the ' back ' button.

    Otherwise, history.back(-1) it will take you to the session previous search in Google to get the HTML code and place it in object HTML/text at the bottom of each page of dashboard

    which will restore the last session he values he's running not not all previous values

    Thank you
    Saichand.v

  • How to get the configuration of the feature for UIMap value?

    Hi all
    Right now, I do a function that needs to get the value of configuration of the feature for the UIMap, anyone have the solution for this or is it just imppssible?

    You can get the values of business Invoking 'Base' = "C1-GetFeatureConfiguration" and then call the user interface mapping, where the BS is included.

  • Switching between the 2 sets of values controlling the axis y in a xy chart.

    All, morning

    I am very new to this (like 2 days now) and will soon sit the Labview core 1 and fundamental measure, bare with me!

    I'm basically extraction 2 string values that is issued by a Board of Directors, I have by IP, one value for line voltage and the second measure concerns the battery voltage.

    I would like the option to use a control switch to differentiate between what is entered the chart at the push of a button.

    Is there a way to do this?

    Thank you very much

    Alex

    Have you tried the Choose function?

  • Between the operator on systimestamp do not return data

    create the table test_ts1 (timestamp);

    insert into test_ts1 values (systimestamp);

    insert into test_ts1 values (systimestamp-interval '1' time);

    commit;

    Select * from test_ts1 where one between systimestamp - interval '1' time and systimestamp;

    do not return data, could you please help? I would if necessary the param values.

    --

    Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production

    PL/SQL Release 11.2.0.2.0 - Production

    "CORE 11.2.0.2.0 Production."

    AMT for Linux: Version 11.2.0.2.0 - Production

    NLSRTL Version 11.2.0.2.0 - Production

    Thank you

    Mahesh

    2 options.

    1 convert your datatype of the column of TIMESTAMP WITH time ZONE SCHEDULE

    SQL > create table test_ts1 (a timestamp with time zone);

    Table created.

    SQL > insert into test_ts1 values (systimestamp);

    1 line of creation.

    SQL > insert into test_ts1 values (systimestamp-interval '1' time);

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > select *.
    2 of test_ts1
    3 where one between systimestamp - interval '1' time and systimestamp;

    A
    ---------------------------------------------------------------------------
    MAY 19, 14 09.06.01.135799 AM - 04:00

    2 convert SYSTIMESTAMP TIMESTAMP.

    SQL > DROP TABLE TEST_TS1 IS SERVING;

    Deleted table.

    SQL > create table test_ts1 (timestamp);

    Table created.

    SQL > insert into test_ts1 values (systimestamp);

    1 line of creation.

    SQL > insert into test_ts1 values (systimestamp-interval '1' time);

    1 line of creation.

    SQL > commit;

    Validation complete.

    SQL > select *.
    2 of test_ts1
    3 where one between systimestamp - interval '1' time and systimestamp;

    no selected line

    SQL > select *.
    2 of test_ts1
    3 where one between Mount (systimestamp timestamp) - interval '1' time and cast (systimestamp timestamp);

    A
    ---------------------------------------------------------------------------
    MAY 19, 14 09.04.09.132503 AM

  • XOR operation for Hex values

    Dear Sir.

    I must apply the Xor operation to 03, 01, 57 & values Hex C9.

    The Calculater programmer I listed as: '03 Xor 01 Xor 57 C9 Xor = 9 c ". Finally, the output is 9 c.

    How to implement the same operation LabVIEW?

    Kind regards

    Chick S

    Try this

  • How to disable the page for a value change event processing

    I am trying to find a solution to a requirement and is currently working on use cases using the HR schema.

    I have a text entry box in the page that accepts a new Department name.

    The value change listener method on it called a bean of support to verify the uniqueness of the name of the Department. (I'm an iteration through the lines of the Departments table to check if the value is unique)

    Now, I need to disable the page and display an hourglass, so what this control and display a message at the end of the treatment.

    I have this job except that I don't know how I can disable the entire page and see an hourglass.

    I have to use Javascript for this?

    Hello

    I've had this work now after the use of clientListener as below.

    Binding = "#{backingBeanScope.backingBean.IT1} '"

    ID = "it1.

    valueChangeListener = "#{backingBeanScope.backingBean.checkUnique} '"

    autoSubmit = 'true '.

    Validator = "#{backingBeanScope.backingBean.validateDeptName}" > "

    Type = "valueChange" / >

    Thanks for your help.

    References: http://www.oracle.com/technetwork/developer-tools/jdev/1-2011-javascript-302460.pdf

Maybe you are looking for

  • Question of Gmail RFC 5321, fails to send emails

    I use Gmail with TB 38.3.0 on MAC OSX 10.9.5. In the last days, I was repeatedly making the following failure message: "An error has occurred when sending mail. The mail server responded: 5.1.2 the specified address is not a valid address of RFC 5321

  • Display the full path to the extensions?

    Hey there,I just found out that you can do the full path of the visible plugins in topic: config, it's useful to get rid of some annoying plugins, I don't want or need.Now I wonder if it is also a way to activate this for extensions? I know that the

  • Impossible to use any website with Java

    Good then since I updated to Firefox 4 I can't use any Java at all. I tried searching for a solution, but none of them work. When I go to an area that requires Java, it tells me I don't have Java installed, and there is nothing wrong with my plugins.

  • OfficeJet 4630: anyone can print reliaby with Officejet 4630 under Windows 10 (64-bit) using wireless?

    I have a couple of PCs. Both run Windows 10 (64-bit). An upgrade from 8.1 64-bit. The other is Windows 7 ultimate (64 bit). I bought Officejet 4630 at the end of September. So far I have not been able to print from a reliable PC at all. Sometimes may

  • Flashing underscore is missing

    Today, my computer crashed because of what I guess is an overload of RAM. When it is first restarted after the crash, he was stuck on a line of flashing underscore one of the phases of my computer to startup (Logo HP > flashing underscore > starts th