Reply
Searching a database
Old 05-24-2005, 10:45 PM Searching a database
fambi's Avatar
Ultra Talker

Posts: 339
What is the best statement to use when searching a table?

Let's say there are 10 columns and i am looking for any occurence of the string 'ee', what is the best way of doing that?

Thanks.
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
When You Register, These Ads Go Away!
     
Old 05-24-2005, 11:41 PM
Uche's Avatar
Extreme Talker

Posts: 174
Location: Nigeria/Lagos
SELECT STATEMENT.

$sql = mysql_query (" SELECT blash blah WHERE so so = that
__________________
Life is just lyke a school where everybody goes to learn one or two thing. the more u school, the more u learn more about school..The more we live our lifes.. the more we learn more about life.
http://www.smartsoft-ng.com
Uche is offline
Reply With Quote
View Public Profile Visit Uche's homepage!
 
Old 05-25-2005, 12:14 AM
mtishetsky's Avatar
Super Spam Talker

Posts: 972
Name: Mike
Location: Mataro, Spain
select * from mytable where column1 like '%ee%' or column2 like '%ee%' or .... or column10 like '%ee%'
or better
select * from mytable where concat(column1, column2, ... column10) like '%ee%'
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 05-25-2005, 06:28 AM
fambi's Avatar
Ultra Talker

Posts: 339
Quote:
select * from mytable where concat(column1, column2, ... column10) like '%ee%'
I like that one.

I'll give it a try and get back to you.

p.s. Is that case-sensitive???
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 05-25-2005, 06:42 AM
mtishetsky's Avatar
Super Spam Talker

Posts: 972
Name: Mike
Location: Mataro, Spain
No, it isn't. This will find strings containing either Ee or eE or EE or ee
__________________
Free Mobile Phone Themes

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 05-25-2005, 07:12 AM
fambi's Avatar
Ultra Talker

Posts: 339
Any idea on how to get case insensitive?
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 05-25-2005, 06:27 PM
fambi's Avatar
Ultra Talker

Posts: 339
Ok. Apparantley it is possible to do a SELECT using a REGEX:

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

Unfortunately, i still can't understand REGEX properly.

How do i write a case insensitive SELECT statement for a string of characters that can come in the begininng, middle or end of the data?

Merci beaucoup.
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 05-25-2005, 07:02 PM
fambi's Avatar
Ultra Talker

Posts: 339
Here it is:

SELECT * FROM column WHERE REGEXP '(ee)'.
__________________
Sending sms from a website or application is easy!
Read this great tutorial that uses our bulk sms gateway.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Reply     « Reply to Searching a database
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16147 seconds with 13 queries