Wildcards with leading characters help?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
recci
Forum Commoner
Posts: 42
Joined: Tue Jul 29, 2008 10:01 pm

Wildcards with leading characters help?

Post by recci »

I have been asked to create 4 wildcard selects one of which must have a leading character.

I take it all a wildcard select is, is something like this:


SELECT * FROM example WHERE age LIKE '2%' ;

The one thing I'm not sure about is the leading character thing?

Anybody got any example of a basic select wildcard query with leading character in it?

cheers
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Wildcards with leading characters help?

Post by califdon »

recci wrote:I have been asked to create 4 wildcard selects one of which must have a leading character.

I take it all a wildcard select is, is something like this:

SELECT * FROM example WHERE age LIKE '2%' ;

The one thing I'm not sure about is the leading character thing?

Anybody got any example of a basic select wildcard query with leading character in it?

cheers
You've already got it, right there, unless they're asking for something different--oh, assuming that the field is Text. If `age` is a numeric field (and you should ordinarily never store someone's AGE in a table, it will be meaningless next year! always store the date of birth, or at least year of birth), you would need to use a numeric function, such as WHERE age BETWEEN 20 and 29.
Post Reply