Need 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
shakeel
Forum Newbie
Posts: 12
Joined: Wed Jan 16, 2008 4:15 am

Need help

Post by shakeel »

Hello

I want to get all rows from a table where "Title" column beginning with any number. What should I use in Like operator. I am using MySql.

thanks.
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: Need help

Post by vargadanis »

Hi!

I know a simple way to do it but it is very unsophisticated:

Code: Select all

SELECT * FROM `table` WHERE nev LIKE '0%' OR '1%' OR '2%' OR '3%' OR '4%' OR '5%' OR '6%' OR '7%' OR '8%' OR '9%'
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Need help

Post by onion2k »

You can use regular expressions in SQL...

Code: Select all

SELECT *
FROM `table`
WHERE 1
AND `title` REGEXP '^[[:digit:]].*'
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: Need help

Post by vargadanis »

Here we go.. I told u mine was a simple solution..
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Need help

Post by califdon »

shakeel, in the future, please do not use vague, general Subjects like "Need help." Those of us who spend a lot of time in this forum do not usually even read such posts. If the questioner doesn't have enough interest to give us an indication of what kind of help is requested, we just skip them.
shakeel
Forum Newbie
Posts: 12
Joined: Wed Jan 16, 2008 4:15 am

Re: Need help

Post by shakeel »

Thanks to all
User avatar
vargadanis
Forum Contributor
Posts: 158
Joined: Sun Jun 01, 2008 3:48 am
Contact:

Re: Need help

Post by vargadanis »

Next time, please, put some info in the subject of the topic so that more peeps might pay attention. :P
Post Reply