Chris Nizzardini, Salt Lake City Utah, Web Developer Specializing in LAMP+Ajax Since 2006

My Blog

Here is my awesome blog. You can find information on programming, linux, documentation, tips for code and database optimization, my thoughts and rants, and whatever else I feel like sharing. Feel free to contribute to the blog by posting comments and asking questions.
SQL

mysql removing characters from end of value

Here’s a quick MySQL trick a co-worker helped me figure out today. This roughly equates to PHPs substr($var,0,-2) functionality.

1
SUBSTRING(field, 1, (LENGTH(field) - 2))

So if the fields value was 12345xx this would change the returned value to 12345.

Related posts:

  1. looping through form fields in javascript
  2. Doing Math in JavaScript umm…sucks
  3. Using MySQL Functions in WHERE Clauses Breaks Speed Gains from Indexing?
  4. JavaScript snippet for handling credit card readers

Leave a Reply