Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you limit the number of words or sentences shown from a query. 1

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi all,

Just wondering how I can limit the a query displayed to one sentence when the result from the database would be a paragraph.

thanks in advance,

dunskii
 
To be more fair...

Code:
<CFSET Repar=Replace(Query.Paragraph,&quot;!&quot;,&quot;.&quot;,&quot;ALL&quot;)>
<CFSET Repar=Replace(Repar,&quot;?&quot;,&quot;.&quot;,&quot;ALL&quot;)>
<CFSET Repar=ListFirst(Repar,&quot;.&quot;)>

#Repar#
 
Hello, Is there a way to limit the output by number of characters, say I only wanted to display the first 50 from a given field?
 
Great. Thank you. And since I have your ear and I can not figure out how to start my own question, I am making an internal search of my database from inputted keyword(s). I am trying to use LIKE in a query that checks each field of each table:
<cfquery name=&quot;checkindexes&quot;
datasource=&quot;myDb&quot;
dbtype=&quot;ODBC&quot;>select * from <cfoutput>#getindexes.table#</cfoutput> where <cfoutput>#getindexes.field#</cfoutput> Like '%'+keyword+'%'</cfquery>

<cfoutput>

If my field contains only say two words and the keyword entered is one of them I get a result. However, if the word is in a larger field, it is not found. I have tried words such as &quot;the&quot; which were present many times.

Would appreciate any advice. Well, preferably some that pertains to the question.


 
<cfquery name=&quot;checkindexes&quot;
datasource=&quot;myDb&quot;
dbtype=&quot;ODBC&quot;>
select * from #getindexes.table#
WHERE #getindexes.field# Like '#keyword#'
</cfquery>

Should work!

You may have some problem with the variable table names...

Thanks and if this helpls, please click the &quot;Click here to mark this post as a helpful or expert post!&quot; after your through on my reply...
 
Just a warning... searching a database like this can really kill performance. Where you're searching for text inside the contents of database columns, especially where you're using the LIKE operator, you're likely to see significant performance improvements by searching a Verity collection of a query against the database.
 
Oh, boy. SOmething else I do not know about. I assume a verity collection is static information which contains all the database info in some organized fashion?

I have always relied upon the kindness of strangers.
 
Exactly. You execute a regular query against the database that returns all the data you might want to search, and then index that data using the Verity Search Engine. Verity organizes and optimizes the data for searching. Then, when you want to search, instead of querying the database, you search the Verity index. Depending on how much data you're querying, you may need to then go back to the database to query it for all the data -- but this time, your Verity search has armed you with the primary keys for the rows you want, so this database query is much faster and less resource-intensive on the database server.

For more information, look in your documentation at the tags <cfindex> and <cfsearch>, specifically as they pertain to indexing a query.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top