Using like with select clause
Hi experts,
I have a problem where i feel i should catch filtered resultset on to my internal table and i feel using LIKE.
But if i use LIKE '%AMIT%'
will it store
AMIT
amit
Amit ie all possible combination irrespectin of any case ?
Will it be case insenstive or not ?
HI,
using like in select is case sensitive.
do like this for ignoring the case.
TABLES:mara.
SELECT * from mara.
IF mara-matnr cp 'm*'.
WRITE:/ mara-matnr.
ENDIF.
ENDSELECT.
rgds,
bharat.
Similar Messages
-
Hi,
I have a query something like ...
Select ....
where
b.prodname like 'SHAFT GEAR%' or b.prodname like '%FRONT GEAR%' or b.prodname like '%BREAK 4K%'
and
b.prodname like
(select company name from companyms
where <some comdition>
order by 3,6
I am stucking at :
b.prodname like
(select company name from companyms
where <some comdition>
i.e. how do I give select query with like operator.
In above query I want b.prodname like above and those company name for which I am giving condition. Company names are stored in other table and I want to select and use them with like operator.
Thanks.create table stock
prodname varchar2(50)
insert into stock values ('MICRO FRONT PANEL');
insert into stock values ('ZEBRA FRONT SHAFT');
insert into stock values ('KOBRA SHAFT GEAR');
insert into stock values ('T RUBBER TUBES');
insert into stock values ('MICRO TUBES PANELS');
insert into stock values ('HEFT SHAFT GEAR');
SELECT * FROM STOCK;
PRODNAME
MICRO FRONT PANEL
ZEBRA FRONT SHAFT
KOBRA SHAFT GEAR
T RUBBER TUBES
MICRO TUBES PANELS
HEFT SHAFT GEAR
6 rows selected.
create table companyms
company_name varchar2(50)
insert into companyms values ('MICRO');
insert into companyms values ('CHOPRA');
insert into companyms values ('H.P.');
insert into companyms values ('T');
insert into companyms values ('BEST BROTHERS');
insert into companyms values ('FIVE STAR');
SELECT * FROM COMPANYMS;
COMPANY_NAME
MICRO
CHOPRA
H.P.
T
BEST BROTHERS
FIVE STAR
6 rows selected.
Actually I have little big query which have inner join with couple of more tables and suppose query returned me to select those rows who have SHAFT GEAR or FRONT GEAR or BREAK 4K of MICRO or ZEBRO or ABC company.
So, I have query like :
select ...
.... some inner join...
.... some outer join
.... some union
SOME MORE WHERE CLAUSES ... ETC. ETC...
where b.prodname (b means stock table) like 'SHAFT GEAR%' or 'FRONT PANEL%'
FOR MICRO or ZEBRA or ABC company. -
Using LIKE in SELECT ..... WHERE
Hi,
I need to do pattern matching during SELECT so that a table field contains or is the same as an input variable. How can I accomplish this?
Regards,
NandithaHere is the "help" for the syntax of LIKE in SELECT statement.
<i>
f [NOT] LIKE g
Addition:
... ESCAPE h
Effect
The condition is met for a table entry if the statement "f (does not) equal the pattern in g" is true for the values of f and g. f must always be a field descriptor, and g an ABAP field. If f has the value NULL, then the result of the check for the statement is unknown. Within a pattern, there are two special characters:
'_' (underscore) stands for any single character.
'%' (percentage sign) stands for any sequence of characters, including an empty string.
Examples
Example to select all customers whose name begins with 'M':
TABLES SCUSTOM.
SELECT ID NAME FROM SCUSTOM
INTO CORRESPONDING FIELDS OF SCUSTOM
WHERE NAME LIKE 'M%'.
WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
ENDSELECT.
Example to select all customers whose name contains 'huber':
TABLES SCUSTOM.
SELECT ID NAME FROM SCUSTOM
INTO CORRESPONDING FIELDS OF SCUSTOM
WHERE NAME LIKE '%huber%'.
WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
ENDSELECT.
Example to select all customers whose name does not contain 'n' as the second character:
TABLES SCUSTOM.
SELECT ID NAME FROM SCUSTOM
INTO CORRESPONDING FIELDS OF SCUSTOM
WHERE NAME NOT LIKE '_n%'.
WRITE: / SCUSTOM-ID, SCUSTOM-NAME.
ENDSELECT.
Notes
LIKE can only be used for alphanumeric database fields. In other words, table field f must have Dictionary type ACCP, CHAR, CLNT, CUKY, LCHR, NUMC, UNIT, VARC, TIMS or DATS. The comparison field g must always have type C.
The maximum length of the pattern is 2n - 1 characters, where n is the length of field f.
Trailing spaces are ignored in comparison field g. If a pattern contains trailing spaces, you must enclose it in single inverted commas ('). If your pattern is enclosed in inverted commas and you also want to include inverted commas as part of the pattern, the inverted commas in the pattern must be doubled.
You cannot use this variant in the ON addition to the FROM clause.
</i>
Regards,
Rich Heilman -
I am trying to gather conditional data from a table based on data from another as shown below :
SELECT NEW_ITEM.CD, CLIENT_DISCOUNT.SHOPPER_ID,
If CLIENT_DISCOUNT.DISCOUNT<=NEW_ITEM.MAX_DISC then NEW_ITEM.BASE_PRICE*((100-CLIENT_DISCOUNT.DISCOUNT])/100)Else NEW_ITEM.BASE_PRICE*((100-NEW_ITEM.MAX_DISC)/100) AS CAT_PRICE
End If
FROM NEW_ITEM, CLIENT_DISCOUNT
WHERE CLIENT_DISCOUNT.SHOPPER_ID='Ted';
but i am getting the error "FROM is not where expected".
So my questions are :
1. If it is possible to put If ... Then ... Else inside a Select query and
2. If yes, what is the correct syntax.
Thank you in advance.You can use a CASE... END statement in SQL to achieve the desired result.
Your query would look something like this :
select n.cd, c.shopper_id, CASE WHEN c.discount <= n.max_disc THEN n.base_price*((100 - c.discount)/100)
ELSE n.base_price*((100 - n.max_disc)/100)
END as ItemPrice
from new_item n , client_discount c where c.shopper_id='Ted'
Ideally your query should have one more condition like n.itemId = c.itemId in the where clause to limit the
query results otherwise it will result in a cartesain product.
Chandar -
Using LIKE with a variable in a report query
Probably an stupid question, but I can't find the answer on this forum or by trying. How do use LIKE and a variable together in a query?
The following solutions don't work f.e.:
LIKE :P310_ENTITEITID%
LIKE ':P310_ENTITEITID%'Hi Elmo
Try '%'||:P310_ENTITEITID||'%'
Elsie -
Howto use jsp with where-clause restriction for viewObject
hello there,
i am currently trying to figure out how to pass parameters via url to the jsp,
so that the corresponding viewobjects where clause can be extended and i only get the select-results that i want. i am familiar with doing this in a stright java-environment but don't know how to implement it in a jsp-client.
does anyone know something about this or can name me a ressource i can read about that.
Thanx
Selim Keserthank you, but i have only 19 days left for
my diploma and nobody in this company can help me with this issue.
what i need is an example or something like a reciept about what to do
to achieve the following:
I want to type in an url like:
localhost:8080/myapp/browse.jsp?customerid=123
so that i can extend the where-clause in my ViewObject
and only see the rows of customer 123 in my jsp.
it is a bit hard for a newbie to figure out how to pass down the parameters way down to the ViewObject. I am shure that this is easy to do once one understands the how it works. This is my first "Web-Experience" and I am running out of time.
Thanx
Selim Keser -
Hello,
I'm using 9.2.0.5.0 production and 9.2.0.7.0 development.
I have a string such as: '4388:4410:4411:4412:4413:4414:4415:4416'
I need to use this string in a SQL statement (not PL/SQL) such as:
SELECT originalcalledpartynumber Agent, count(1) "# Calls"
FROM voip_cdr
WHERE originalcalledpartynumber IN (replace('''4388:4410:4411:4412:4413:4414:4415:4416''', ':', ''''||','||''''))
GROUP BY originalcalledpartynumber
where the colons are replaced by a single quote then a comma then a single quote which this should be resolved to:
'4388','4410','4411','4412','4413','4414','4415','4416'
I'm getting no rows returned, but there are rows. If I use '4388','4410','4411','4412','4413','4414','4415','4416' in the select instead of the replace such as:
SELECT NULL link, originalcalledpartynumber Agent, count(1) "# Calls"
FROM voip_cdr
WHERE originalcalledpartynumber IN ('4388','4410','4411','4412','4413','4414','4415','4416')
GROUP BY originalcalledpartynumber
I get:
AGENT # Calls
4388 1304
4410 348
4411 1932
4412 3241
4413 361
4414 3221
4415 3382
4416 4
8 rows selected.
So the REPLACE function does not work using it in an IN clause?
Can someone help me with this?
Thanks,
Joehttp://asktom.oracle.com/pls/ask/f?p=4950:8:8444496587549649868::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:210612357425
http://asktom.oracle.com/pls/ask/f?p=4950:8:8444496587549649868::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:110612348061 -
How to use "like" with variables at right hand side ?.Urgent Pls..
How can I compare a column with a combination of columns.
columns are character
select ...from table1 t1,table2 t2 where
t1.col1 like t2.col1 || t2.col2
eg:
where p.upc = '0' ||r.upc_ccode||r.upc_mnum|| r.upc_mcode
this restricts LHS to start with 0 and values starting with non zero are not taken for comparison.I need to include those values also in comparison
p.upc can start with any char 0 -9.
p.upc ->char(12)
r.upc_commod_code||r.upc_mfg_num|| r.upc_mfg_it -> total char(11)
Any Help would be highly appreciated !
Thanks In Advance!Hi ,
There is a simple solution to your problem....Its name is Regular Expressions.
Read the docs found in links:
http://www.oracle.com/technology/pub/articles/saternos_regexp.html
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_regexp.htm
http://www.oracle.com/technology/oramag/oracle/03-sep/o53sql.html
NOTE: You have to use Oracle10g version!!!!!
Regards,
Simon -
Trying to use Spry with Select List
I have a dataset that is static xml. .In the xml file I have
a node called categoreis and then repeating node of store name,
phone and address in that category. There are around 15 categories
and a total of 100 stores with address and phone. I can create the
select list and add the onchange event to tell Spry which row of
data was selected in the drop down. I do not understand how to
generate the detail region that shows the stores for that
particular category. Any help would be appreciated.Always include the following information when asking a question:
<ul>
<li>Full APEX version</li>
<li>Full DB/version/edition/host OS</li>
<li>Web server architecture (EPG, OHS or APEX listener/host OS)</li>
<li>Browser(s) and version(s) used</li>
<li>Theme</li>
<li>Template(s)</li>
<li>Region/item type(s)</li>
</ul>
taepodong wrote:
Hi All,
Bit at loss what i am doing wrong here. Trying to change a field (previously in textfield) to a drop down select list. All works except one. It looks like Multi-selector even though I set the type as Select List
http://i.imgur.com/Hz7tP.png
Got no idea what I have to do to change it to drop down. Many Thanks.If you are on apex 4.x, you might have set the Allow Multiple Selection to Yes
Edit the select list item > Settings > set Allow Multi Selection to No
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/item_types001.htm#HTMDB28627 -
Hi there!
Sorry if this has been answered before, but the forum search ignores '%' so I could not find anything relevant. I'm completely at a loss here guys so any help will be really appreciated.
I've got a database adapter that executes a "pure SQL" query:
select * from supplier t
WHERE t.idsupplier = #idSupplierParam OR #idSupplierParam2 IS NULL
AND t.name like '%' || #nameParam || '%' OR #nameParam2 IS NULL
AND t.address like '%' || #addressParam || '%' OR #addressParam2 IS NULL
AND t.description like '%' || #descParam || '%' OR #descParam2 IS NULL
I've got a single record in my DB with name= 'supplier1'
When I execute my bpel passing 'sup' as nameParam and nameParam2, everything is right and I get my supplier1 in the results.
BUT if I pass 'asdfghj' as name, I still get my 'supplier1' in the results ¿¿¿???
¿Is this a bug? ¿Am I doing something wrong? Thanks in advance!!No, but thanks for trying. Iif you had read my post you'd had found that I wrote
+When I execute my bpel passing 'sup' as nameParam and nameParam2+
But I double checked against that just in case. I made a test query
select * from supplier t WHERE t.name like '%' || #nameParam || '%'
And no matter what I pass as nameParam, I always GET ALL THE RECORDS in my table. ¿Any idea what's going on? It's like param is being ignored and the query that is executed is select * from supplier t WHERE t.name like '%%' which would of course return everything in the DB. :(
Help plz!! -
Hi experts,
I am writing a Function module to get data from a table.
Import :
desc TYPE ZTABLE-DESCRIPTION.
Now when desc = te*
REPLACE ALL OCCURRENCES OF '*' IN
desc WITH '%' .
SELECT *
FROM ZTABLE
INTO CORRESPONDING FIELDS OF TABLE t_list WHERE DESCRIPTION LIKE desc.
.. With is the table fetches all records where description starts with " te " .. here te is case senstive
So if description is "Test " or " TEST " or "tE" ......... so on.. i want this like to be made case in sensitive
Coz user can search as per his/her way...
Regards,
Bijale_sel-sign = 'I'.
e_sel-option = 'BT'.
e_sel-low = 'te%'.
e_sel-high = 'TE%'.
APPEND e_sel TO i_sel .clear e_sel.
e_sel-sign = 'I'.
e_sel-option = 'BT'.
e_sel-low = 'tE%'.
e_sel-high = 'Te%'.
APPEND e_sel TO i_sel .clear e_sel.
SELECT *
FROM ztable
INTO CORRESPONDING FIELDS OF TABLE t_list
WHERE description IN i_sel.
or
SELECT *
FROM ztable
INTO CORRESPONDING FIELDS OF TABLE t_list
WHERE description+0(2) in ( 'te%', 'TE%' , 'Te%', 'tE%'). -
How To: Use Like '*' with DoQuery
As anyone who has tried to use a LIKE in their SELECT statement will know, if you are using the DoQuery method of the SAPbobsCOM.Recordset object, LIKE's are not supported. Here is a workaround that seems to work fairly well for our needs.
Code Sample:
findValueLength = findValue.Length.ToString();
sqlQuery = "SELECT CardName AS ReturnValue1 FROM OCRD WHERE LEFT(CardCode," + findValueLength + ") = '" + findValue + "' AND CardType <> 'S'";
rs = (SAPbobsCOM.Recordset) sapConnect.SboCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
rs.DoQuery(sqlQuery);
Basically, if you select anything who's left x characters are the same as the find value, it will return the same results as doing a LIKE findValue*.
Message was edited by: David WallThank you for sharing your solution, David.
Lutz Morrien -
Using Keyfigures with selections in a query
Hi Experts,
I am designing a query which has the selection criteria as (Condition1) OR ( Condition2 and Condition3) and all the selection are for a single month. For this I have created a Structure and am using two selections.
I also need to display a SINGLE keyfigure which displays the number of records for the month. The problem that I am facing is, as soon as I hide the selections the Keyfigure values do not show up.
Any ideas.
Thanks
RBHi Vijay,
Though it should not make a difference whether the result values are suppressed or not because I am using selections in a structure but still I tried this and it did not work. Let me redefine my problem to ease the understanding of the logic.
select all sales order whose (priority is high) OR ( status is inprocess And owner = X)
For the above criteria I created one selection which had the restriction on Priority as high and the other selection has status as inprocess and Owner = X.
Now I do not want to show the selection criteria on the report so I have hidden both the selections.
I also want to display a keyfigure which counts the number of records.
The problem is If I hide the selections it does not display the number of records but If I show the selections then it does. I do not want to display the selections but still do want the number of records value to appear.
I hope this time I was more clear.
Thanks
RB -
Use of LIKE in where clause of select statement for multiple records
Hi Experts,
I have a account number field which is uploaded from a file. Now this account numbers uploaded does not match fully with sap table account numbers but it contains all of the numbers provided in the file mostly in the upright positions.
For example in file we have account number as 2ARS1 while in sap table the value is 002ARS1.
And i want to fetch data from sap table based on account number uploaded. So, i am trying to use LIKE with for all entries but its not working as mentioned below but LIKE is not working with FOR ALL ENTRIES.
data : begin of t_dda occurs 0,
dda(19) type c,
end of t_dda.
data : begin of t_bukrs occurs 0,
bukrs type t012k-bukrs,
end of t_bukrs.
data : dda type t012k-bankn,
w_dda type t012k-bankn.
CONCATENATE '%'
'2ARS1'
INTO W_DDA.
MOVE W_DDA TO T_DDA-DDA.
APPEND T_DDA.
CLEAR T_DDA.
free t_bukrs.
SELECT BUKRS
FROM T012K
into TABLE t_bukrs
for all entries in t_dda
WHERE BANKN like t_dda-dda.
Can anybody suggest what should i use to get the data for multiple account numbers using one select statement only instead on using SELECT UP TO 1 ROWS in LOOP....ENDLOOP ?
Thanks in advance,
AkashHi,
yes, For All entries won't work for LIKE with '% '.
I think the other alternative is go for Native SQL by writing sub-query
sample code is here:
data: begin of i_mara occurs 0,
matnr like mara-matnr,
matkl like mara-matkl,
end of i_mara.
exec sql.
select matnr, matkl from mara where matnr in (select matnr from marc) and matnr like '%ma' into :i_mara
endexec.
loop at i_mara.
write:/ i_mara-matnr, i_mara-matkl.
endloop.
hope u got it.
regards
Mahesh
Edited by: Mahesh Reddy on Jan 21, 2009 2:32 PM -
Using record with sql in clause
hi friends
i have a record and which have only some id's. and i have to use it with select in
like
Select * from aaaa where id in record
how can we do it?JAVAMAN2 wrote:
hi friends
i have a record and which have only some id's. and i have to use it with select in
like
Select * from aaaa where id in record
how can we do it?Well, a record is certainly better-er than an eight track, so you're on your way, soon you'll have a CD, then a DVD, unless you deviate and end up with a Laser Disc.
Now, how about you post some technically relevant information describing in great detail 1) what you have and 2) what you want.
For the former, you would want to tell us your oracle version
select * from v$version;And all the pertinent information (technically speaking), as well as what you expect and why.
If you can't take the time to post a thorough question, how can you expect anyone to provide a thorough (and correct) answer?
Maybe you are looking for
-
Creating Calculations in RTF templates
Is there any way of creating calculations or formula functions within rtf's?
-
Hi there, I have some questions about cvs daily snapshot. The problem is for the package eo-snapshot in AUR Here is the PKGBUILD # Contributor: Sebastien Piccand <[email protected]> pkgname=eo-snapshot pkgver=20060411 _ver=11Apr2006 pkgrel=1 pkgdesc=
-
Error in CRMXIF_PRODUCT_MATERIAL_SAVE
Hi, I am using CRMXIF_PRODUCT_MATERIAL_SAVE this fm to create product. I give the existing set type to CUSTOMER_SET_DATA , I'm getting error message "User-defined set type ZFORM does not exist in BDOC structure" . please give me some ideas. Regards,
-
$LS_COLORS stopped working (for user, not for root)
Good day. Some time ago, "ls" stopped paying attention to my color settings when coloring output for my user, while still working for root. For both root and my user, I set $LS_COLORS through ~/.bashrc as "eval $(dircolors -b)" but while this works
-
Cannot find photo stream folder on my PC
I cannot find the Network and Internrt option on my control panel in order to find my photo stream folder. Trying to locate my photos!!