473,398 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

hwo to use REGEXP to find rows with any numbers in between?

170 100+
hey guys,

i got a question on REGEXP in SQL

if i have a row containing the info

NAME : 12344455667678

how can i use a SELECt with REGEXP
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM `mml log` WHERE Commands REGEXP 
  2.  
such that it will search anything in the field with NAME : $input
in which the $input is given by my users

so say is $input is 234 or 444 or 5566
it will still return me the row containing the info above?
Jun 4 '08 #1
8 1777
r035198x
13,262 8TB
You don't need REGEXP for that. Just a simple like with the % wildcard will do.
If you insist on REGEXP then you can read about how to use it from here.
Jun 4 '08 #2
poolboi
170 100+
hm...i tried using wild card too

the reason why it doesn't work is 'cos
i want to make sure the number is attached to NAME

so if i have 2 rows each containing;

NAME :11223345565
CLASS: 18373556879


if i use use wild card with %556%
it's gonna return both the rows
but i only want it attached with NAME
Jun 4 '08 #3
r035198x
13,262 8TB
hm...i tried using wild card too

the reason why it doesn't work is 'cos
i want to make sure the number is attached to NAME

so if i have 2 rows each containing;

NAME :11223345565
CLASS: 18373556879


if i use use wild card with %556%
it's gonna return both the rows
but i only want it attached with NAME
I'm missing something here.
Are NAME and CLASS two different columns?
Jun 4 '08 #4
r035198x
13,262 8TB
I'm missing something here.
Are NAME and CLASS two different columns?
Wait, I think I get you now.
You can use concat. Concat 'NAME' with the wild carded input.
Jun 4 '08 #5
Atli
5,058 Expert 4TB
If you have "NAME :11223345565" in a single field, you shouldn't!
You should never have two pieces of data inside the same field.
Check out this article.

If that is how it is tho, you could simply do:
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM tbl WHERE col LIKE "NAME: %345%"
The wild-cards can be anywhere inside a string, not just at the ends.
Jun 4 '08 #6
r035198x
13,262 8TB
..
You should never have two pieces of data inside the same field.
...
Amen .
Jun 4 '08 #7
poolboi
170 100+
hm.i get what u mean
by right it should be under a column name

actualli that field of mine is called commands
commands that ppl use during a telnet session
sometimes commands can be very long with number
and i just wanna query say wildcard the number and get the results

with regards to
Expand|Select|Wrap|Line Numbers
  1.  
  2. NAME = %345%
  3.  
i've tried and doesn't worked too..
Jun 5 '08 #8
r035198x
13,262 8TB
hm.i get what u mean
by right it should be under a column name

actualli that field of mine is called commands
commands that ppl use during a telnet session
sometimes commands can be very long with number
and i just wanna query say wildcard the number and get the results

with regards to
Expand|Select|Wrap|Line Numbers
  1.  
  2. NAME = %345%
  3.  
i've tried and doesn't worked too..
Wildcards are used with the LIKE operator not the = operator.
Also I think you want to do
Expand|Select|Wrap|Line Numbers
  1.  LIKE 'NAME:%345%'
Jun 5 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Lukas Holcik | last post by:
Hi everyone! How can I simply search text for regexps (lets say <a href="(.*?)">(.*?)</a>) and save all URLs(1) and link contents(2) in a dictionary { name : URL}? In a single pass if it could....
6
by: Oliver Spiesshofer | last post by:
Hi, I would like to replace all strings in a table with regexp: the strings contain the substring "-na", and I would like to replace the whole table field with the original content but without...
5
by: Syed Ali | last post by:
Hello, I am trying to create a regexp to express non letters and space. I tried using: var myreg = new RegExp (""); However, it is not working. Basically I want to allow only words with...
26
by: rkleiner | last post by:
Is there a regular expression to find the first unmatched right bracket in a string, if there is one? For example, "(1*(2+3))))".search(/regexp/) == 9 Thanks in advance.
1
by: jgabbai | last post by:
Hi, I have data in a row, such as "34,54,12,134" I need to select rows where they match certain numbers, and not others, so match 34,12 and not 134 (ie the above row would fail, but...
17
by: Justin Emlay | last post by:
I'm hopping someone can help me out on a payroll project I need to implement. To start we are dealing with payroll periods. So we are dealing with an exact 10 days (Monday - Friday, 2 weeks). ...
5
by: Vidéotron | last post by:
Hi, A bit new to "more complex" expression... So here the case I have: bla bla bla{TPL,some texte or numbers}bla bla bla. I figured out how to write the expression to extract the "{TPL,some...
3
by: vendredi5h | last post by:
Hello all, I would like to create a Regexp that (very simplified situation) read a web page and retreive some informations in the table rows (<tr>) that include a particular text except if it...
6
by: Christian Sonne | last post by:
Long story short, I'm trying to find all ISBN-10 numbers in a multiline string (approximately 10 pages of a normal book), and as far as I can tell, the *correct* thing to match would be this:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.