Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
LIKE operator and search phone without area code
Message
From
21/10/2005 11:18:54
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01061088
Message ID:
01061094
Views:
18
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>In HELP I could not find LIKE operator. I see LIKE() function definition.
>
>I want to be able to search by phones without area code. I have field as cArea_Code+cExchange+cLast_Four.
>
>Here is my code:
>
>*---------------------- Location Section ------------------------
>*   Library: 	Asearchcontrols.vcx
>*   Class: 		Cntphonesearch
>*   Method: 	Getwhereexpression()
>*----------------------- Usage Section --------------------------
>*)  Description:
>*)
>
>*   Scope:      Public
>*   Parameters:
>*$  Usage:
>*$
>*   Returns:
>*--------------------- Maintenance Section ----------------------
>*   Change Log:
>*       CREATED 	08/12/2005 - NN
>*		MODIFIED
>*----------------------------------------------------------------
>LOCAL lcRetVal
>lcRetVal = ""
>DO case
>	case NOT EMPTY(this.txtAreaCode.Value) AND NOT EMPTY(this.txtExchange.Value) AND NOT EMPTY(this.txtLastFour.Value)
>		lcRetVal = SUBSTR(STRTRAN(this.cSeparator + this.cFldname, this.cSeparator, "+##ALIAS##."),2) ;
>           + " LIKE '" + this.txtAreaCode.Value + this.txtExchange.Value + ;
>           this.txtLastFour.Value  + "%'"
>    case EMPTY(this.txtAreaCode.Value) AND NOT EMPTY(this.txtExchange.Value) AND NOT EMPTY(this.txtLastFour.Value)
>		lcRetVal = SUBSTR(STRTRAN(this.cSeparator + this.cFldname, this.cSeparator, "+##ALIAS##."),2) ;
>           + " LIKE '???" + this.txtExchange.Value + ;
>           this.txtLastFour.Value  + "%'"
>ENDCASE
>
>this.cWhereExp = STRTRAN(m.lcRetVal, "##ALIAS##", this.cAliasname)
>
>RETURN m.lcRetVal
>
>
>If I put area code, it works. Without area code it immediately produces no records found message. What is wrong here? Can I combine ??? and % in one string?


N,

The ? for the sql LIKE is _ (underscore)
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform