SQL Command for searching
I have a database with fields containing large amounts of text. I wish to be able to search the text in the database using a sql command. I have a number of problems:
1. I will not know in advance how many words the user will be searching for eg 'Holidays' or 'Holidays in England' so how can I split these up and search effectively?
2. What is the SQL command to use to check in the database field to see if it has any of the related strings?
Any help would be greatly appreciated.
1.Use StringTokenizer to split the words in your search string
StringTokenizer st = new StringTokenizer("query_string"," ");
2.Suppose it has 2 tokens then, construct a query like this, (You can use st.countTokens() to get the token count)
Select * from table where col1 like '%token1%' or col1 like '%token2%'
Hope this helps.
Sudha
Similar Messages
-
Need help on Sql command for count
Hi,
I have the following table.
Temp_Set Table
ID Names Action
1 John Delete
2 John Add
3 Mary Update
4 Sim Add
5 Sim Update
How do I do a SELECT sql command for count(names) > 1 ?
Please kindly advise me. Thank you very much.It doesnt work when I do this
SELECT * FROM Temp_Set
HAVING Count(names) > 1
It prompts me the following error:
ORA-00937: not a single-group group function
00937.00000 - "not a single-group group function"
*Cause:
*Action:
Error at Line:16 Column:7i am not sure but you can try this:
SELECT B.* FROM
(SELECT NAMES, COUNT(1) CNT FROM TEMP_SET GROUP BY NAMES) A, TEMP_SET B
WHERE A.NAMES = B.NAME
AND CNT > 1 -
I am attempting to write a SQL command for a Crystal report that links tables from two different databases, both of them Progress databases.I keep getting syntax errors that the table from the other db (meaning not the one I opened in DB Expert) can't be found. If someone has experience with Progress or otherwise has any ideas it would be greatly appreciated.
I'm not familiar with Progress, but does it have something like MS SQL's OPENQUERY using Linked Servers (which allows you to query a different DB server from the one you're connected to)? If not, you'll probably have to use two different SQL Commands to base the report on, then use Crystal to link the returned data sets. (I'm assuming "a different database" means "a different database server", not a different database on the same server instance...)
HTH,
Carl -
I am looking for a SQL statement for Search Box in the sample application.
Anyone knows about these issues?
Thanks in advance,
Sam
Edited by: samNY on Mar 13, 2009 2:18 PMThank Manish,
Could you tell me how to restrict in following codes?
select
e.EQUIPMENT_ID,
e.HOST_NAME,
e.SERIAL_NUMBER,
e.CITY,
e.ROOM,
e.RACK,
e.CR_DT,
e.CR_USR,
e.LM_USR,
e.LM_DT,
e.TASK_TASK_ID
from SVR_EQUIPMENT e
where
instr(upper(e.SERIAL_NUMBER),upper(nvl(:P1_REPORT_SEARCH,e.SERIAL_NUMBER))) > 0 and
instr(upper(e.CITY),upper(nvl(:P1_REPORT_SEARCH,e.CITY))) > 0 and
instr(upper(e.CR_USR),upper(nvl(:P1_REPORT_SEARCH,e.CR_USR))) > 0 or
instr(upper(e.LM_USR),upper(nvl(:P1_REPORT_SEARCH,e.LM_USR))) > 0
Thanks for all again,
Sam -
What is the sql command for SELECT with OR condition
Hi
What is the correct sql command for doing select with or condition??
SELECT * from TempData
WHERE port = '123'
OR serialnumber = '555'
So if there is a port = 123 or if there is a serialnumber = 555, I will get a successful select.
Thanks for helping a newbie!!Hi
What is the correct sql command for doing select with
or condition??
SELECT * from TempData
WHERE port = '123'
OR serialnumber = '555'
So if there is a port = 123 or if there is a
serialnumber = 555, I will get a successful select.
Thanks for helping a newbie!!Make sure you bracket your OR conditions
eg
SELECT * from TempData
WHERE column = 'VALUE'
and port = '123'
OR serialnumber = '555'
is read as
SELECT * from TempData
WHERE (column = 'VALUE'
and port = '123' )
OR serialnumber = '555'
which is not the same as
SELECT * from TempData
WHERE column = 'VALUE'
and ( port = '123'
OR serialnumber = '555' ) -
SQL Command for deleting T-Code for roles
Hi Experts
I want to delete the transaction from the role name by using SQL Command in MS-SQL Server instead of going to /npfcg -> zwa_xyz (role name for user) and transaction code is CR01,CR01,CA01 Etc.,
I have so many transaction code which is taking time to delete one by one.
So is there any SQL Statement to delete the t-code for that rolename
Delete from tablename where t-code=xyz and rolename in ('zwa_xyz',zwa_123')
regardsHey,
SAP does not support executing update/insert/delete SQLs on their tables,
(the only SQL they support are select, and updates that they publish in their official site, such as notes in service.sap.com/notes)
is is probably due to the fact that sap contains about 30,000 of table,
and sometimes SAP uses cluster tables (which are difficult to handle in DB)
in addition, each and every SP adds/remove table or changes existing tables.
For example, you probably don't know that changing rule, would
create a change document (cluster table - CDHDR, CDPOS and etc),
If you want, it is very easy to get the full list of the table (and the sql) that are updated
(as I mentioned before, it is not recommended to run this sql, because it is not supported!!!)
just run transaction ST05 while deleting transaction from role,
when you display the list, press shift+F8 (or summerized trace from the menu),
and they search (Ctrl+F) the words: update or insert or delete.
You can use standard API such as BAPIs (such as BAPI_USER_*)/IDOCs(such as USERCHANGE),
and execute them from the portal and any other place (even in EXCEL or OS->meaning command line).
Here more information on executing RFCs:
1. in order to execute an RFC from excel, you should install SAP gui on the client that would execute the RFCs to the SAP, and you would have to write VBA code.
2. in order to execute an RFC from command line, this is a little bit more difficult,
sap provide RFC sdk (in service.sap.com/SWDC)
3. in order to execute an RFC from .net you can use the .net connector,
more information is here:
NW RFC SDK - is there a guide somewhere?
4. You can also, execute an RFC using Web service,
by creating web-service from the RFC in SE37.
I guess It will take more time to develop this they just executing the SQL.
If you need more information in executing an RFC,
please decide which option is your favorite,
and I would add information... -
Sharepoint full farm backup generates sql logs for search application differential backups
We are running full farm backups for sharepoint. Backup completes normally but SQL logs are generated for differential backups for search service application.
it says something like:
Database differential changes were backed up: database: search_serv.......
Thanks,
BasitThis can happen for a few reasons, such as is disk contention or network issues. Are you backing up to a shared directory on the SQL Server? If not, try that.
Trevor Seward
Follow or contact me at...
This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs. -
Sql Commands for Backup and restore database
Hi,
What are the SQL commands used for database backup nad restore?
Is it possible to use these command in pl/sql block or it is used only
from sql plus?
Thanks
Jobin .SPhttp://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/intro005.htm
-
How to do SQL Command for this
Hi,
I have 2 tables.
TempTT TempTB
Name Place DeviceName Products
Factory_55 Indonesia Factory_55##11122 Pencils
Factory_22 USA Factory_22##23444 Pens
Factory_33 UK Factory_22##82922 Erasers
How do I do my SQL command if I wanted to extract DeviceName from TempTB
if TempTT.Name is found in TempTB.DeviceName??
Please advise me. Thank you!!I do not want to join them. I show my table here again. I wanted to SELECT DeviceName from TempTB if the Name from TempTT is found in DeviceName of TempTB. Thanks alot!
TempTT
Name Place
Factory_55 Indonesia
Factory_22 USA
Factory_33 UK
TempTB
DeviceName Products
Factory_55##11122 Pencils
Factory_22##23444 Pens
Factory_22##82922 Erasers -
Using sql command, how do I get rid of the 'to' in my string
Factoryto_510 ->> Factory_510
Thank you very much!REPLACE
-
SQL error for searches within Arch forums
Hi guys,
Since last night, when ever I try to run a search, whether it be a pre-defined search like New Posts or last 12h, or a keyword search within the search page, I get an error:
Could not delete old search id sessions
DEBUG MODE
SQL Error : 1016 Can't open file: 'phpbb_search_results.MYI' (errno: 145)
DELETE FROM phpbb_search_results WHERE session_id NOT IN ('b8a882a76bd524ca2cae00763907813a', 'ff63868080729e0ee81c83f1e2b08fac', '153ae6e2b7dfa3b1acab764caf6251a9', '61230f3df774fc9e05bbd91b9de8ab6a', 'ebea35cab271f97e47a0edeb867f350b', '852bae4b6e661b50c6e656eacab5204f', '874a6ac043dfb52bd2162d92f3700b28',
... (goes on for ages) ...
'eb520a66784db4079cf64fbf16316d65', '9f2f2ebe525f98222e32c1cefffd7ea1')
Line : 663
File : search.php
This is rather annoying as I can't look for the latest posts easily.There's already a discussion about it here:
http://bbs.archlinux.org/viewtopic.php?t=17004
Locking to keep continuity. -
Help with sql command for inventory cost change report
Inventory Cost Changes within date range.
Columns on report
Item LastDateChanged CurrentCost PriorCost
Source File-TransHst (Type 14 is inventory cost change)
example data
Type,Item,DtChg,Cost
14,15825,02/01/2014,357.00
14,45832,03/15/2014,95725.00
14,15825,10/01/2013,322.00
14,45832,06/22/2012,94632.00
example output needed
Item LastDateChanged CurrentCost PriorCost
15825 02/01/2014 357.00 322.00
Using Crystal Reports 2008 with Oracle Database
I cannot create sql to retrieve data to create report.
Need Item, Last Change Date, Current Cost and Prior Cost as output of sql
ThanksHI Jerry,
I don't know real syntax of your database, try below SQL, you may have to modify the syntax wherever it is required.
Select t.Item, Max(t.DtChg),(case when year(t.dtchg) = Year(sysdate) then t.Cost else 0) as currentCost,
(case when year(t.dtchg) = Year(sysdate)-1 then t.Cost else 0) as PriorCost
From TransHst t
Where Type=14
Group by t.Item
Thanks,
Sastry -
Need PL/SQL Command for to check all rows value for child record and update
Hi All,
i want to update one field following by
one to many relationship for example
in child applet status field is value is "Closed" for all child record then parent value also should update to closed
Note: if one child record field status is "Open" don't do the update operationYou can do it in single UPDATE operation.
Here is sample & Result:
create table PA (id varchar2(3), name varchar2(12), STATUS varchar2(12));
insert into pa values('001','Cary','Open');
insert into pa values('002','TOM','Open');
create table boy (par_id varchar2(3), id varchar2(4), name varchar2(12), status varchar2(12));
insert into boy values('001','ABC1','Cary','Open');
insert into boy values('001','ABC2','Mac','Closed');
insert into boy values('001','ABC3','Ray','Closed');
insert into boy values('001','ABC4','NALLY','Open');
insert into boy values('002','ABC5','ME','Closed');
insert into boy values('002','ABC6','SHE','Closed');
UPDATE PA
SET STATUS='Closed'
WHERE NOT EXISTS
(SELECT 1
FROM BOY
WHERE BOY.PAR_ID=PA.id
GROUP BY BOY.PAR_ID,
BOY.STATUS
HAVING SUM(DECODE(BOY.STATUS,'Open',1,'Closed',0,0))>0
select * from pa;
001 Cary Open
002 TOM Closed -
MS Access SQL Command Automatic Update
Does anyone know the SQL command for automaticlly incrementing a number in Microsoft Access?
I'm writing a program in Java and I have these 3 fields of ID, name and address, and I want the ID to be automicattly incremented each time a name and address is added.If you have a table like this.
customer_table: id_column, name_column
Then you do an insert like the following
insert into customer_table(name_column) values('xxx')
After that the id_column will have a value in it. For the next insert the id_column will have a different incremented value. -
I have been forced to write some simple scripts for Windows users who use Oracle. I used to write in bash/ksh and have no experience at all about windows scripts. What I figured out is :
cmd file:
echo off
set script_dir= .
set log=%script_dir%\log\db.log
set scrsql=%script_dir%\db.sql
sqlplus /nolog @%scrsql% >> %log%
so my questions are :
- I would like to have all commands ( batch and sql) visible inside cmd file. Is it any way to put sql commands line by line into cmd file ?
- how to redirect output of sql command ( for example simple select ) to screen or file
- how to put external parameter into sql command ( for example select xx from yy where zz=@param)
KP>well, I do not see too much responses for my question - maybe it was not clear enough ?
Let me write it in this way:
I have a short ksh script:
+#!/usr/bin/ksh+
LOG_DIR=$ORACLE_HOME/dba/scripts/log
LOG=$LOG_DIR/log.txt
VAR=$2
export ORACLE_SID=$1
sqlplus -s '/as sysdba' << ! >> $LOG << call sqlplus commands inside a script
whenever sqlerror exit failure;
select * from table where columnsvalue= $VAR; << use variable in sql query
+!+
How to convert, in most easy way, such a script to windows batch. If I get an answer it solves almost all problems I have.
Maybe you are looking for
-
Retaining original filenames in Save For Web droplet
Automation from LR to PS is going groovy, but, The output files are all being renamed by the 'save for web' dialogue box to the filename saved inside the action that the droplet points to.. So file #1 is saved ok, File #2 renamed as file #1 and repla
-
My Render is not working in CC 2014- any ideas?
Just installed CC 2014 and I can't render at all. All of the usual shortcuts and even using the Menu bar won't render the timeline.
-
Header(S) and Item(S) in ALV Grid
Hi All, Is it possible to have multiple headers and its corresponding item details in ALV Grid Display? The requirement is to convert the display of MB51 in ALV Grid. Is it possible in ALV Grid to have this kind of display? Best Regards, Kumar.
-
How can I rotate a book in adobe digital editions? My book is sideways.
The book I am looking at was scanned sideways because of the format. I need to flip, or rotate so I can read it.
-
BI Server performance too slow
Hi experts, I am facing an issue, my OBIEE sits on a Unix Platform. And many time the server performance is too slow, when I check the processes, Java under Orabi user is using more than 50% of the CPU utilization. I need to find the root cause behin