473,382 Members | 1,375 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,382 software developers and data experts.

Like query syntax question

Im trying to write a like query

select * from table1 where column1 like 'abc[0-9]%'
(I realize this syntax isnt correct)

I want to include any chars from 0-9 in that spot...
Does anyone know how to do this?

-Craig
cs********@hotmail.com
Jul 20 '05 #1
2 4008
Im trying to write a like query

select * from table1 where column1 like ’abc[0-9]%’
(I realize this syntax isnt correct)

I want to include any chars from 0-9 in that spot...
Does anyone know how to do this?

-Craig
cs********@hotmail.com
Craig,

The elegant way of solving your problem is with regular expressions.
Search for "mysql regex" using a search engine.

Otherwise you have to write:

like ’%abc1%’ or like ’%abc2%’ ....

yikes!

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/mySQL-query-...ict140719.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=471490
Jul 20 '05 #2
Craig Stadler wrote:
Im trying to write a like query

select * from table1 where column1 like 'abc[0-9]%'
(I realize this syntax isnt correct)

I want to include any chars from 0-9 in that spot...
Does anyone know how to do this?


Standard SQL expressions used with the LIKE predicate have only two
wildcards: '_' matches a single character (like '.' in UNIX-style
regular expressions), and '%' matches any sequence of characters (like
'.*' in UNIX-style regular expressions)

MySQL extends SQL with a predicate that matches more complex regular
expressions, including many of the wildcards familiar to UNIX users.

In your example, you should be able to get the result you want with the
following query:
select * from table1 where column1 REGEXP '^abc[0-9]'

See also:
http://dev.mysql.com/doc/mysql/en/Pattern_matching.html
http://dev.mysql.com/doc/mysql/en/Regexp.html

Regards,
Bill K.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Craig Stadler | last post by:
Im trying to write a like query select * from table1 where column1 like 'abc%' (I realize this syntax isnt correct) I want to include any chars from 0-9 in that spot... Does anyone know how...
4
by: dp | last post by:
After looking and looking, it appears that Access ADPs graphic query designer won't display: update customer set = . from customer, where customer. = .; It comes up with the "Query...
2
by: Lyn | last post by:
Hi, How do you bind the output columns from a UNION query when the fields from the two tables have different names? Consider this query (WHERE clauses omitted)... SELECT SurnameBirth,...
2
by: neilmcguigan | last post by:
this is more of a text parsing/regex kind of question, but i figured i'd start here. please let me know if this should go somewhere else. I'd like to implement google-like search syntax, a la...
6
by: T. Wintershoven | last post by:
Hi Can someone please tell me whats wrong with the last line of the query below. The first three lines work fine but when i add the fourth line i get an error message (see text at ERROR...
0
by: schan | last post by:
Hi there, I was wondering if someone could shed some light on a problem I have no idea on how to fix. I created an Excel Add-In that uses an ADO connection to an Access database on a file...
5
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the...
10
by: Daniel | last post by:
In Microsoft Access I can write a query that includes the criteria: Between Date()-7 And Date() to retrieve the records from a table that fall within the last week. I'm trying to write a...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
1
by: neha2007 | last post by:
I am trying to use a MS Access Database in an vb.aspx page. I have written the following two queries.. but they are giving me errors which i am unable to fix.ANy help in this regard would be...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.