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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for Character 1

Status
Not open for further replies.

greggb

Programmer
Dec 6, 2003
30
0
0
US
Sorry for the elementary question, but I am racking my brain trying to figure out the best way to search for a particular character (or string) columnn by column in a table, regardless of where it might be in the cell.

Can anyone help me?
 
AT( ) Function
Returns the beginning numeric position of the first occurrence of a character expression or memo field within another character expression or memo field, counting from the leftmost character

Attitude is Everything
 
greggb;

Code:
SELECT * ;
    FROM mydbf ;
    WHERE ([Z] $ UPPER(myfield1))

* OR

SELECT * ;
    FROM mydbf ;
    WHERE ([Z] $ UPPER(myfield1) ;
        OR ([Z] $ UPPER(mfield2)) ;
        OR ([ABC] $ UPPER(mfield3)))

HTH - Wayne

 
Greggb,

Are you saying that you don't know which field the character will be in? If so, you need to loop through all the fields in the record, something like this:

SELECT MyTable
FOR x = 1 TO FCOUNT()
IF TYPE(x) = "C" OR TYPE(x) = "M"
* Do this with char and memos only
str = EVAL(FIELD(x))
IF AT(SearchChar,str) > 0
* Found
* Take appropriate action here
EXIT
ENDIF
ENDIF
ENDFOR


I haven't tested this, but I think it'll work.

Mike



Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top