Tag: mysql

  • Split multiline pipe-delimited string into columns and rows in MySQL

    Do you have an output that is in comma or pipe-delimited format and you want to go digging in a MySQL database for the data that corresponds to that output? Don’t feel like cutting and pasting and/or scripting in a language better suited for the task and just want it all to happen in MySQL […]

  • Getting a count of the rows in all of your ActiveRecord models

    Warning: Going through ActiveRecord is likely not something you want to do in production unless you have a replica database that your script or your model can point at. See the second part for MySQL and PostgreSQL examples in SQL. How do you enumerate your models? For apps created under Rails 5 app or later, […]

  • MySQL Ignores Right Padded Spaces?

    When working on an established Rails project, we noticed that trailing spaces weren’t getting trimmed off. Discussion ensued about whether to do data cleanup and then someone noticed that the where method in Rails didn’t care about the spaces. Not having seen this in my PostgreSQL days, I was assuming that there was some magic […]