Jump to content

mysql query A-Z


esport

Recommended Posts

Hi,
I'm trying to do query that matches the first character of a feild. Rather than selecting all rows from the table then doing an 'if' statement to filter out the rows you dont wont, is there a way doing a mysql query that only matches the first character?
Thanks

Daniel
Link to comment
Share on other sites

[quote author=esport link=topic=100939.msg398996#msg398996 date=1153183671]
Thanks mate, works great. I guess its not case sensitive?[/quote]

Correct. Did it need to be? If so, I *think* you need to modify the query to ... BINARY left(somefieldname,1) = 'your choice of case-sensitive letter'
Link to comment
Share on other sites

You can also use a simple REGEXP for this, though I've not done the performance comparisons... personally, I find REGEXs easier to read, but I spend all my time staring at Perl code, so I'm biased.  BTW, MySQL 4.1+ requires the use of a COLLATION to get the old binary attribute, AFAIK.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.