Welcome Guest, Not a member yet? Register   Sign In
sql search
#1

[eluser]basty_dread[/eluser]
Is there any sql query in which i could query on the database which will only count the string with a number in it..

for example these are record in the database..

123 error
dominic 12343
fruits

the sql query num_rows should return 2 record..which is 123 error and dominic 12343
i tried this code but with limitation.

Code:
select vKeyword from mykeyword where vKeyword like '1%'
#2

[eluser]danmontgomery[/eluser]
Code:
SELECT `vKeyword` FROM `mykeyword` WHERE `vKeyword` REGEXP "[[:digit:]]{1,}"
#3

[eluser]basty_dread[/eluser]
i will try this out thank you very much for posting and helping..
#4

[eluser]jmadsen[/eluser]
nice, noctrum! I learned something today.

for those who want to learn more about the regexpr he gave,

http://dev.mysql.com/doc/refman/5.5/en/regexp.html

the [[:digit:]] is called a character_class, and there's a list of handy ones.

the {1,} is an alternate way of writing + (i.e., a+ can be a{1,} )


Reducing the number of rows and the SIZE of the rows is another performance enhancing method many web developers overlook. (just think "Everytime you write 'SELECT * ...' a kitten dies")




Theme © iAndrew 2016 - Forum software by © MyBB