Jump to content

Select Statement And Wildcards


riz.pro
 Share

Recommended Posts

hi,i have table with a column (say name) with values as below--------------name--------------M04897M05678MSF00089MSF00111T167854T89732TB91SF_014TB92SF_112i want to select all the records excluding T167854 and T89732. ie where name = T followed by an integer.The below query doesn't workSELECT * FROM temp WHERE name='T[123456789]%';is there anything wrong with it? or How do i accomplish it?i m using MySql 5.1.31

Link to comment
Share on other sites

Yes, there's something wrong with that query, you're telling it to select records where the name is the string "T[123456789]%". If you want to use a pattern you need to use a regex. Check the user comments on this page for several examples:http://dev.mysql.com/doc/refman/5.1/en/regexp.html

Link to comment
Share on other sites

  • 2 weeks later...
Yes, there's something wrong with that query, you're telling it to select records where the name is the string "T[123456789]%". If you want to use a pattern you need to use a regex. Check the user comments on this page for several examples:http://dev.mysql.com/doc/refman/5.1/en/regexp.html
thanks for sharing , I add it into my bookmark !!!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...