Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google      Sign In   
  • Create Account

Subscribe to HRA Now!

 



Are you a Google Analytics enthusiast?

Share and download Custom Google Analytics Reports, dashboards and advanced segments--for FREE! 

 



 

 www.CustomReportSharing.com 

From the folks who brought you High Rankings!


Sponsored Content

 

 
 

Photo
- - - - -

Asterisks (*) In Mysql Queries?


  • Please log in to reply
1 reply to this topic

#1 Nathan Malone

Nathan Malone

    HR 5

  • Active Members
  • PipPipPipPipPip
  • 497 posts

Posted 22 January 2005 - 09:01 PM

Hey, I'm still working away at my search engine (it was harder then I thought it would be!) but I ran into one little problem in a mysql query.

I want to select a mysql table row(s) where the first part of a column starts with $asdf2 but the next part can be anything. I think that there is a way to do a wild card with an asterisk but I can't get it to work.

BTW, for those of you who are wondering why I'm trying to do this, I need to find url's that are in directories that are banned in the robots.txt file.

Below is some code roughly the way it would need to be.

CODE
mysql_query("UPDATE table_name SET table_column = 'asdf' WHERE asdf2 = '$asdf2*'");


Oh, I checked out the php manual but I couldn't find anything on how to do it there.

Any help is appreciated...

#2 chrishirst

chrishirst

    A not so moderate moderator.

  • Moderator
  • 5,879 posts
  • Location:Blackpool UK

Posted 22 January 2005 - 09:35 PM

'%' is a wildcard in SQL so

SQL
mysql_query("UPDATE table_name SET table_column = 'asdf' WHERE asdf2 LIKE '" . $asdf2 . "%'");





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users