Very Newbie LIKE operator question

HI, I am a newbie just starting out with sql. I am trying to find all customers with last name that starts with L. This is what I tried and got no rows selected.
SELECT *
FROM Customer
WHERE LastName LIKE '*L';
What is the correct syntax?

in 10g
SQL> ed
Wrote file afiedt.buf
  1* select empno,ename from emp where regexp_like(ename,'^A|^a')
SQL> /
     EMPNO ENAME
      7499 ALLEN
      7876 ADAMSso for you
select empno,ename from emp where regexp_like(ename,'^L|^l')

Similar Messages

  • LIKE OPERATOR QUESTION

    Hi All,
    Quite simply I don't really understand two things.
    1) How is the LIKE operator is working to return both columns.
    2) When to use the LIKE operator and when to use the relation operator.
    Thanks.
    (CODE)
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa LIKE bb
    --returns both columns
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa = bb
    --returns nothing
    (/CODE)

    Hi,
    DaveyB wrote:
    Hi All,
    Quite simply I don't really understand two things.
    1) How is the LIKE operator is working to return both columns.The WHERE clause (whether it contains LIKE or anything else) will only control the number of rows: every row will have the same numberr of columns.
    2) When to use the LIKE operator and when to use the relation operator.Use LIKE when you want to use "wildcards" (% or _).
    Use other operators (like =) when you don't have wildcards.
    (CODE)
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa LIKE bb
    --returns both columns
    SELECT *
    FROM ( SELECT TO_DATE ('01/01/2009 12:01:01', 'DD/MM/YYYY HH24:MI:SS') aa,
    TO_DATE ('1-Jan-2009') bb FROM DUAL
    WHERE aa = bb
    --returns nothing
    (/CODE)It's great that you're trying to format your code! I wish everyione did that.
    Use square brackets ([ and ]) if you want to use [CODE] and [/CODE] tags.
    LIKE operates on strings. Don't use a DATE where a string is required. Do some experiments like the ones you tried just using strings, if you want to see how LIKE behaves.

  • SQL Query With Like Operator - Performance is very poor - Oracle Apps Table

    Hi,
    I'm querying one of the Oracle Applications Standard Table. The performance is very slow when like operator is used in the query condition. The query uses a indexed column in the where clause.
    The query is..
    select * from hz_parties
    where upper(party_name) like '%TOY%'
    In the above case, It is not using the index and doing full table scan. I have checked the explain plan and the cost is 4496.
    select * from hz_parties
    where upper(party_name) like 'TOY%'
    If I remove the '%' at the begining of the string, the performance is good and it is using the index. In this case, the cost is 5.
    Any ideas to improve the performance of the above query. I have to retrieve the records whose name contains the string. I have tried hints to force the use of index. But it is of no use.
    Thanks,
    Rama

    If new indexes are disallowed, not a lot of good ones, no.
    If you know what keyword(s) are going to be searched for, a materialized view might help, but I assume that you're searching based on user input. In that case, you'd have to essentially build your own Text index using materialized views, which will almost certainly be less efficient and require more maintenance than the built-in functionality.
    There may not be much you could do to affect the query plan in a reasonable way. Depending on the size of the table, how much RAM you're willing to throw at the problem, how your system is administered, and what Oracle Apps requires/ prohibits in terms of database configuration, you might be able to force Oracle to cache this table so that your full table scans are at least more efficient.
    Justin

  • Problem in JDBC , when using LIKE operator. - VERY URGENT

    Problem in JDBC , when using LIKE operator.
    LINE 1 : String temp = "AA";
    LINE 2 : String query = "select * from emp where EMPNAME like '*temp*' ";
    LINE 3 : Staement st = con.createStaement();
    LINE 4 : ResultSet rs = st.executeQuery(query);
    '*' character is not getting evaluated. In MS ACCESS2000 only * is accepted instead of '%'. Moreover in MS ACCESS the like operator has to be used within double quotes as a String. whereas in other databases, it accepts single quotes as a String.
    Ex:
    In MS ACCESS
         select * from emp where ename like "*aa*";
    Other Databases
         select * from emp where ename like '%aa%';
    In my situation iam passing a Variable inside a like operator and '*' is used.
    For the above Scenario, Please help me out.
    If possible Kindly let me know the exact Syntax.
    Please give me the answer as LINE1,LINE2,LINE3,LINE4,
    I have verified in JDBC Spec also, it has been specified to use escape sequence.that too did not work.
    Due to this, My project is in hold for about 4 days. I could not find a suitable solution.
    Please help me out.

    I made a LIKE clause work with M$ Access, using PreparedStatement and the % wildcard:
                escapeStr                   = "%";
                String sql                  = "SELECT USERNAME, PASSWORD FROM USERS WHERE USERNAME LIKE ?";
                PreparedStatement statement = connection.prepareStatement(sql);
                statement.setString(1, ("user" + escapeStr));
                ResultSet resultSet         = statement.executeQuery();
                while (resultSet.next())
                    System.out.println("username: " + resultSet.getObject("USERNAME") + " password: " + resultSet.getObject("PASSWORD"));

  • Like operator with PowerQuery

    Hi Everyone
    Please help me to construct a PowerQuery With help of LIKE operator SQL Query
    Below is my sample Query
    select * from
    abc where
    LastModifiedDate
    like
    '2012-02-06%'
    Thanks In Advance..

    Hi
    Not sure if you are trying to:
    use Like in a PQ, in which case Chris Webb's blog is very helpful  Implementing A Basic LIKE/Wildcard Search Function In Power Query or
    are you trying to pass a parameter through to a SQL Query in which case I just posted a suggestion to a similar question here How
    to pass date dynamically to SqlQuery in PowerQuery
    Hope this helps

  • LIKE operator is not working in SQL Query in XML file

    Hi Gurus,
    LIKE operator is not working in SQL query in XML template.
    I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
    <?xml version="1.0" encoding="WINDOWS-1252" ?>
    <dataTemplate name="catalogDataTemplate" description="Magazine
    Catalog" defaultPackage="" Version="1.0">
    <parameters>
    <parameter name="id" dataType="number" />
    <parameter name="ename" dataType="character" />
    </parameters>
    <dataQuery>
    <sqlStatement name="Q1">
    <![CDATA[
       SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
    </sqlStatement>
    </dataQuery>
    <dataStructure>
    <group name="EmployeeInfo" source="Q1">
    <element name="EmployeeName" value="ename" />
    <element name="EMPNO" value="empno" />
    <element name="JOB" value="job"/>
    <element name="MANAGER" value="mgr" />
    </group>
    </dataStructure>
    </dataTemplate>
    if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
    Appreciate your help,
    Shyamal
    email: [email protected]

    Hi
    Well for a start, you are doing some very strange conversions there. For example...
    and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
    and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
    and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
    and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
    AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
    AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
    Cheers
    Ben

  • LIKE operator in multiple-row subqueries

    Hello,
    in a test i saw 2 questions:
    Which operator can be used with a multiple-row subquery?
    A. =
    B. LIKE
    C. BETWEEN
    D. NOT IN
    E. IS
    F. <>
    Answer: D
    and
    Which two statements about subqueries are true? (Choose two.)
    A. A single row subquery can retrieve data from only one table.
    B. A SQL query statement cannot display data from table B that is referred to in its
    subquery, unless table B is included in the main query's FROM clause.
    C. A SQL query statement can display data from table B that is referred to in its subquery,
    without including table B in its own FROM clause.
    D A single row subquery can retrieve data from more than one table.
    E. A single row subquery cannot be used in a condition where the LIKE operator is used for
    comparison.
    F. A multiple-row subquery cannot be used in a condition where the LIKE operator is used for
    comparison.
    Answer: B & D
    But in the last question, why F is not correct? because the 1st question says that only NOT IN can be used in multiple-row subqueries. I'm confused
    Thanks

    only two, but what principle applies if not specified? First two correct?
    however, in explanation i saw something like this (regarding to the 2nd question)
    Incorrect Answers
    A: A single row sub-query can retrieve data from more than one table.
    C: A SQL query statement cannot display data from table B that is referred to in its subquery,
    unless table B is included in the main query's FROM clause.
    E: A single row sub-query can be used in a condition where the LIKE operator is used for
    comparison.
    F: A multiple-row sub-query can be used in a condition where the LIKE operator is used for
    comparison.
    so, at F: can be used or nor? they aren't so clear. only which operators can be used in multiple-row subquery?

  • Like Operator is not working

    Hi have a table BACKLOG where i have a column called item_number
    I have made report on this table and i have included all item_number. Now i have to create another set of reports where i have to exclude records on basis of item_number.
    For this i have made a static lov which is having values like SERVICE,SAMPLE,EBV
    The item_number is db contains SERVICE,SAMPLE,EBV in them. Examples are
    SERVICE WFR SEN
    SERVICE NRE SEN
    SAMPLE NRE SEN
    SAMPLE WFR SEN
    EBV NRE SEN
    EBV WFR SEN
    In my report i am using the like operator as
    and a.item_number like '%:P2_ITEM_NUMBER%'
    [/CODE]
    I have used the :P2_ITEM_NUMBER because i have a select list in the report page.
    Apart of it i want one more query to exclude the selected value of :P2_ITEM_NUMBER from report
    Thanks in advance
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi
    Well for a start, you are doing some very strange conversions there. For example...
    and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
    and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
    and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
    and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
    AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
    AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
    Cheers
    Ben

  • LIKE operator- change symbol for [all characters]

    I have an input parameter which contains symbols "*" (star symbol), example:
    i_search_par := 'country * street';
    I gonna do query:
    select * from SearchTable
    where col1 like i_search_par;
    I want that the "*" would act the same way as "%"-symbol in LIKE operator.
    So i want that query would return such results:
    'country 1 street'
    'country 200 street'
    and so on.
    What is the better way to achieve this, that "*" is going to be interpreted as a "any number of any symbols"?
    Maybe i can say something like:
    SET SESSION ANYCHAR SYMBOL = "*".
    And after doing that Oracle understands in LIKE operators that star-symbol is like i want?
    Or should i really do string replacement by replacing ""%" to "*" in "i_search_par" and in other 30 such varaibles?

    Hi,
    Sorry, I don't think there's any way to tell LIKE to use different wildcards.
    CharlesRoos wrote:
    I have ca 30 input parameters:
    i_search_par1 := 'country * street';
    i_search_par2 := 'country * street';
    i_search_par30 := 'country * street';Wouldn't it be just as easy to say:
    i_search_par1 := 'country % street';
    i_search_par2 := 'country % street';
    i_search_par30 := 'country % street';?
    >
    And i will use them all like this:
    select * from T
    where Col1 like i_search_par1
    and Col2 like i_search_par2
    and
    Col30 like i_search_par30You could write a very simple user-defined function. It would be slower, but the query would be a tiny bit simpler:
    select * from T
    where my_like (Col1, i_search_par1) = 1
    and   my_like (Col2, i_search_par2) = 1
    and   my_like (Col30, i_search_par30) = 1
    Then you suggest that i sgould do string replacement 30 times for each parameter?Do you mean 1 time for each parameter, or 30 times altogether? Yes.
    Isn't there better solution?
    Maybe database has instruction that changes interpetation of symbol "*" into "%".It would be handy, but I don't think such a thing exists.

  • Like operator not passed to database for nvarchar(max)

    From Crystal Reports 2008 I need to do a keyword search against a data type of nvarchar(max).
    I am using the LIKE operator in my record selection formula.
    When I do a SHOW QUERY the LIKE condition is omitted from the where clause.
    This makes the report run so slow it is useless.
    How can I do a keyword search against an nvarchar(max) data type?
    Thanks,
    Larry
    CR Developer 12.2.0.290, Product type: Full
    SQL Server 2008 r2

    Sorry it wasn't clear what you are doing or why. I assumed you were using the LIKE in the record selection formula to filter on fields like CustomerID etc. which can be passed to the server. You want to filter based on the text in a Description type field field.
    Yes that is going to be very slow having Crystal do it client side, means all of the data will be sent to the local work station and then on the second pass CR will start filtering.
    You could try using a Command Object to use as the data source, CR should simply pass what ever SQL you type in. Copy your existing SQL and then create a new report and use a Command object and paste in the SQL, edit it to include the LIKE operator and see it that works for you.
    Another option is to use a Stored Procedure with a parameter to do the searching, that will force it to do it Server side. DB servers will aways be more efficient at processing filters that ce will be.
    When viewing the report can you not use the Search window, although that is after the fact so it too would mean all data has to come down first...?
    Basically what is happening is CR is testing every word in the nvarchar field, CR isn't very optimized to do that kind of filtering client side and because it's more complex SQL we won't generate the proper syntax to pass it to the server. Also, Cr supports so many data sources and to build that logic into the basic report designer is very complex and not efficient, there are various DB tools that can do that kind of work and CR can connect to them, Universes, Data Integrator etc., those tools are designed to do this type of complex SQL generation.
    Thank you
    Don
    PS - If Jason sees this thread he is a SQL guru and may have some suggestion for you also.
    Edited by: Don Williams on Jun 22, 2011 11:17 AM

  • Characters allowed inside LIKE operator

    Hi,
    DB: Oracle 10g
    SELECT   count(*)
      FROM   mytable
    WHERE   LOWER(mycolumn) LIKE LOWER('%<th sc="row">Havana</th>%')I am not sure if this pattern will be matched by LIKE operator because it has all sorts of
    characters as you can see -> <, = ", /.
    So, my questions
    1. What characters are allowed inside LIKE?
    2. Any other way of doing the same query?
    3. Index on column "mycolumn" will be invalidated by %. right?
    Please advise.
    Thanks.
    Edited by: abyss on Sep 23, 2010 3:50 PM

    even the like statement will do the same(will not use Index) :)
    to answer your first question, the char you have inthe SQL should be fine., I think it will work for all char except for
    %   and _   You can try with the REGEXP as alternate solution
    Edited by: Prasath on Sep 23, 2010 1:56 PM

  • [VB] Like operator not functioning?

    I'm trying to create the following statement in my VB code, but I'm getting a "Sub or Function not defined" error. My question is, how do you use the Like operator with InDesign scripting? InDesign doesn't seem to recognize the Like operator.
    "myCurrentString" contains a letter.
    If myCurrentString Like "[A-z]" Then
    End If
    I'm also trying to do the following:
    If myCurrentDigit Like "[0-9]" Then
    End If

    I couldn't find "RegExp" in the InDesign script model--could you give a bit more information about what this is? I don't know how to iterate through the contents of an XMLElement as individual character objects, so I'm iterating throught XML.contents, putting each character in a basic string variable. I need a way to put strings into a With statement, or a Like operator. I haven't had success with either technique.
    Here's an example:
    strTime = myCurrentXMLElement.contents
    strTime = Trim(strTime)
    strLength = Len(strTime)
    For counter = 1 to strLength
    strTemp = Mid(strTime, counter, 1)
    [This is where I need to find out if strTemp is a letter or a digit]
    Next

  • How to move Firefox4 Tabs to the Bottom like opera the userChome.css #content tabbox { -moz-box-direction: reverse; } does't work ,and tabmix extension is s incompatible with Firefox 4.

    ''Duplicate post, continue here - [https://support.mozilla.com/en-US/questions/780590]''
    I want move Firefox tabs to the bottom like opera
    but the code of userChome.css
    #content > tabbox { -moz-box-direction: reverse; }
    does'nt work,
    and tabmix can do this,but current version of tabmix is incompatible with Firefox 4.

    You can get the development version of Tab Mix Plus which works with Firefox 4 from http://tmp.garyr.net/forum/viewtopic.php?t=10888
    The author of Tab Mix Plus has stated that he is almost ready to release a new version of Tab Mix Plus.

  • Can I use a LIKE operator in an IF statement in a column formula

    This is what I have so far.
    CASE WHEN Opportunity."Sales Type" LIKE '*New Acct' THEN 'Sale to NEW Customer' END
    I want to display 'Sale to NEW Customer' if opportunity type contains the terms New Acct.

    Try this:
    CASE WHEN Opportunity."Sales Type" LIKE '%New Acct' THEN 'Sale to NEW Customer' END
    The LIKE operator requires a % wildcard rather than the * wildcard.
    Mike L.

  • Why the 'LIKE' operator takes so much time to run?

    I have a table T with 3 columns and 3 indexes:
    CREATE TABLE T
    id VARCHAR2(38) NOT NULL,
    fid VARCHAR2(38) NOT NULL,
    val NVARCHAR2(2000) NOT NULL
    ALTER TABLE T ADD (CONSTRAINT pk_t PRIMARY KEY (id,fid));
    CREATE INDEX t_fid ON T(fid);
    CREATE INDEX t_val ON T(val);
    Then I have the following two queries which differ in only one place - the 1st one uses the '=' operator whereas the 2nd uses 'LIKE'. Both queries have the identical execution plan and return one identical row. However, the 1st query takes almost 0 second to execute, and the 2nd one takes more than 12 seconds, on a pretty beefy machine. I had played with the target text, like placing '%' here and/or there, and observed the similar timing every time.
    So I am wondering what I should change to make the 'LIKE' operator run as fast as the '=' operator. I know CONTEXT/CATALOG index is a viable approach, but I am just trying to find out if there is a simpler alternative, such as a better use of the index t_val.
    1) Query with '=' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val = '3504038055275883124';
    2) Query with 'LIKE' operator
    SELECT id
    FROM T
    WHERE fid = '{999AE6E4-1ED9-459B-9BB0-45C913668C8C}'
    AND val LIKE '3504038055275883124';
    Execution Plan
    0 SELECT STATEMENT Optimizer=ALL_ROWS (Cost=1 Card=1 Bytes=99)
    1 0 TABLE ACCESS (BY INDEX ROWID) OF 'T' (Cost=1 Card=1 Bytes=99)
    2 1 INDEX (RANGE SCAN) OF 'T_VAL' (NON-UNIQUE) (Cost=4 Card=12)

    I will for sure try to change the order of the PK and see whether there will be any impact to the performance.
    In our application, val is much closer to a unique value than fid. In the example query, the execution plan showed that the index on val was indeed used in the execution of the query. That's why the 1st query took almost no time to return (our table T has more than 6 million rows).
    I was hoping the 'LIKE' operator would utilize the t_val index effectively and provide similar performance to the '=' operator. But apparently that's not the case, or needs some tricks.

Maybe you are looking for

  • Can't transfer files from my PC to my new Mac over our wireless network

    I have a Linksys WRT54G router connected to a cable modem, which is connected to a desktop PC. I have a Dell laptop connected to the internet wirelessly, and my MacBook Pro is also connected to the internet wirelessly. No problem there, the internet

  • Generate a List of Referenced Files?

    Hello, Does anyone know how to generate a list of referenced files in a FrameMaker 8.0 file? I've consulted the User's Manual and online Help, and I can not find this information. Thanks, Amy

  • Can Auto create bookmark when insert a page?

    I know that when I combine multiple PDF file, bookmarks will be automatically created with the file names. However, when I insert page into this combined document, the bookmarks did not auto create. Similarly when I delete a page from this document,

  • How do I find a brush that I created in elements 12....NEED HELP!

    I created this brush, and it saved as number 409, however, when I went looking into the brush section, its no where to be found, even restarted the program to no avail......NEED HELP PLZ!!

  • STO config - supplying plant as vendor

    Hi How can I maintain a plant as a vendor for stock transport order. What changes should I do in the vendor master . Thanks Thara