Re: Using 'Like' in 'sql' query
Re: Using 'Like' in 'sql' query
- Subject: Re: Using 'Like' in 'sql' query
- From: Art Isbell <email@hidden>
- Date: Thu, 10 Apr 2003 17:42:44 -1000
On Thursday, April 10, 2003, at 05:08 PM, Riaz Lalehzari wrote:
String sqlQuery;
sqlQuery = "SELECT firstname FROM Person WHERE firstname like '" +
enteredFirstName + "'"
Then I say - results = EOUtilities.rawRowsForSQL(....);
I've tried manually coding the '*' wildcard and '?' on the ends of the
string, inside and outside the ' symbols. If I enter "Ken*" as my
enteredFirstName it still should work though. But it seems to be
looking for people with the name "Ken*" instead of using a wildcard.
'*' and '?' are Unix, but not generally SQL wildcard characters. If
you instead use EOUtilities.rawRowsWithQualifierFormat() and let EOF
generate the appropriate wildcard characters for the database you're
using, you would use '*' and '?' as wildcard characters in the
qualifier.
But if you must use EOUtilities.rawRowsForSQL() and write your own
SQL, you need to find out which wildcard characters your database uses.
Some databases use '%' and '_' as wildcard characters. If you
hardcode these wildcard characters, you will have to change your code
and recompile if you change to a different database that uses different
wildcard characters which is a downside to imbedding SQL in your code.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.