473,382 Members | 1,376 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.

RLIKE in SQL

296 100+
I am firing the below query for extracting were+10 from the database but its not working. Please correct it.

Expand|Select|Wrap|Line Numbers
  1. SELECT parameter FROM table WHERE parameter RLIKE '\\bwere\\b'
May 30 '08 #1
13 5954
pankajit09
296 100+
I am firing the below query for extracting were+10 from the database but its not working. Please correct it.


Expand|Select|Wrap|Line Numbers
  1. SELECT parameter FROM table WHERE parameter RLIKE '\\bwere\\b'
May 30 '08 #2
Atli
5,058 Expert 4TB
Why are you using the backspace char (\b)?
Have you tried just using 'where'?
May 30 '08 #3
dlite922
1,584 Expert 1GB
I am firing the below query for extracting were+10 from the database but its not working. Please correct it.

Expand|Select|Wrap|Line Numbers
  1. SELECT parameter FROM table WHERE parameter RLIKE '\\bwere\\b'
I'm pretty sure you've got the regex wrong.

What do you mean were+10? Everything that starts with the word lowercase were and up to 10 characters there after?

Might help you better if you post this in the SQL forum also.
May 31 '08 #4
pankajit09
296 100+
Why are you using the backspace char (\b)?
Have you tried just using 'where'?
The string can be like "were+10"

I want an exact match of "were".
Jun 2 '08 #5
pankajit09
296 100+
I'm pretty sure you've got the regex wrong.

What do you mean were+10? Everything that starts with the word lowercase were and up to 10 characters there after?

Might help you better if you post this in the SQL forum also.

"were+10" is just a string.

I want to find the exact occurence of "were".
Jun 2 '08 #6
Atli
5,058 Expert 4TB
If you want an exact match, you should use the LIKE syntax rather than RLIKE.
Expand|Select|Wrap|Line Numbers
  1. SELECT cols FROM tbl WHERE searchCol LIKE 'where';
  2.  
If you want all rows starring with 'where', add the wild-card char (%) after the keyword:
Expand|Select|Wrap|Line Numbers
  1. SELECT cols FROM tbl WHERE searchCol LIKE 'where%';
  2.  
You can add a wild-card anywhere in the stringt. Be careful tho. It's very easy to over-use.
Jun 2 '08 #7
Atli
5,058 Expert 4TB
As this is in no way a PHP problem, I have merged the duplicate thread you posted in the PHP forums with this one.

Please do not to double post your questions, and try to keep them in the appropriate forums.

Moderator
Jun 2 '08 #8
pankajit09
296 100+
If you want an exact match, you should use the LIKE syntax rather than RLIKE.
Expand|Select|Wrap|Line Numbers
  1. SELECT cols FROM tbl WHERE searchCol LIKE 'where';
  2.  
If you want all rows starring with 'where', add the wild-card char (%) after the keyword:
Expand|Select|Wrap|Line Numbers
  1. SELECT cols FROM tbl WHERE searchCol LIKE 'where%';
  2.  
You can add a wild-card anywhere in the stringt. Be careful tho. It's very easy to over-use.

Will it work for substrings also ?

For eg: We have a string "11+firstwere+12"

If we use LIKE then it will return true for the string . It should return false.
Jun 5 '08 #9
r035198x
13,262 8TB
Will it work for substrings also ?

For eg: We have a string "11+firstwere+12"

If we use LIKE then it will return true for the string . It should return false.
if you put like '%where%', rows with "11+firstwere+12" will not be returned.
Jun 5 '08 #10
pankajit09
296 100+
if you put like '%where%', rows with "11+firstwere+12" will not be returned.

No it returns.

I tested it.
Jun 6 '08 #11
r035198x
13,262 8TB
No it returns.

I tested it.
Are you sure the field has "11+firstwere+12" and not "11+firstwhere+12"?
Jun 6 '08 #12
dlite922
1,584 Expert 1GB
No it returns.

I tested it.
Okay, let's end this thread:

1. If you want the EXACT phrase "were" and nothing else, use an equal sign: fieldName = "were".

2. If you want phrases that contain the word "were" use wild cards (the percentage sign %) appropriatly. If you put "%were" it will return anything that ENDs with "were", if you put "were%" it will return anything that STARTS with "were". If you put "%were%" it will return ANY string that contains where, regardless of position.

Good luck,


Dan
Jun 6 '08 #13
pankajit09
296 100+
If you put "%were%" it will return ANY string that contains where, regardless of position.

In the above case it will also return the strings in which "were" is a substring.
I don't want that.
Jun 9 '08 #14

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

Similar topics

0
by: Nils Valentin | last post by:
Hi MySQL fans ;-), I tried to get some experience with converting between the different password formats as describd here: http://www.mysql.com/doc/en/Password_hashing.html So I took this...
2
by: Sam | last post by:
Is there a way to filter 'show processlist'? like show processlist where Host rlike "abc" Thanks, Sam
2
by: news | last post by:
We're trying to make a search form, and are wanting to create links for all the letters a person can click on and will bring up all entries that start with that letter. That part is easy: .......
3
by: starman7 | last post by:
I'm attempting a query that gathers product data for a particular product id. One of the items is designer(s) which can be more than one. The product table has comma separated id's of the...
3
by: Rudy | last post by:
Hello all! This is what I want to do, looking the for the best way to do this. I have a text file that gets created and placed in a folder. I would like to have a watch for that file when it pops...
0
by: Oleg Broytmann | last post by:
Hello! I'm pleased to announce the 0.7.1 release of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as...
9
by: axlq | last post by:
I'm trying to figure out a MySQL query expression to match an email address. Here's the situation: User registers on my site with a "plus style" email address (username+key@example.com). This...
14
by: Archanak | last post by:
Hi, I have 13.8 GB of data. The data is of the following:- 1: Proc Natl Acad Sci U S A. 2003 Aug 19;100(17):9768-73. Epub 2003 Jul 30. Characterization of myotubularin-related protein 7...
4
by: Archanak | last post by:
Hi, I have table like this: select * from sampletest; | title ...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.