Josh Thompson     about     archive     tags

MySQL concatenation and casting

I recently set up my environment for working through SQL for Mere Mortals.

I’ll record some interested tidbits here as I go.

Chapter 5: Concatenation without the || operator

I use MySQL at work, and MySQL doesn’t support the || operator for string concatenation.

So, in the book, an expression like:

ItemOne || ItemTwo

evaluates to ItemOneItemTwo

In MySQL, || is a logical operator, just like in Ruby, so to get the above evaluation, you’d need to use:

CONCAT(ItemOne, ItemTwo)

That would give you ItemOneItemTwo. Of course, string concatenation pairs well with spaces between the strings you’re trying to concatenate, so please know that the CONCAT function can take any number of arguments, for example:

CONCAT(ItemOne, ' ', ItemTwo)

would return ItemOne ItemTwo

>> Read more

2017 In Review & Thoughts on 2018

note: this “annual review” covers three topics. Click on one to skip to it:


I’ve got mixed feelings on annual reviews. I steadfastly refuse to set New Years’ resolutions, and am even shying away from the whole idea of goals.

(“not being goal oriented” is a big idea to unpack, and I’ll do so eventually. I’ve historically been extremely goal oriented, but I’m changing my tune on how healthy for me this is.)

However, I find review, reflection, and planning to be valuable. Here we are.

Step 1 of “doing an annual review” is take a look at what I’ve written in past annual reviews.

I started this whole thing in 2012, but didn’t do any sort of review for 2012, 2013, or 2014. Writing that sentence confirms the value of this review - I wish I had done a review those years, if for no other reason than to remind future Josh what the heck was going on in his life then.

Further validation of this sentiment comes from Patrick McKenzie:

Patrick McKenzie makes generally great recommendations. His recommendation pushed me over the edge.

>> Read more

Cultivate Curiosity, or 'Reasons to be More Childlike'

I’ve had an idea rolling around my head.

I suspect that “being curious” will correlate well with positive outcomes in my life, on pretty much any time horizon, be it days, weeks, or decades. Curiosity feels like a tolerable antidote to boredom, though boredom in and of itself is something to celebrate and embrace.

The goal isn’t to not be bored, it is to not be jaded and closed.

What is “jaded and closed”? I cannot quite define it, but I know it when I see it.

I enjoy spending time with people who are both older than me, and people who are just plain old. When they display traits or attitudes that I either want to emulate or want to avoid, I try to reverse engineer what led to that thing I do or don’t want.

The presence/absence of curiosity has correlated well the presence/absence of other traits I want to emulate.

>> Read more

Setting up for 'SQL Queries for Mere Mortals'

This tweet is from… a while ago. Turns out I didn’t dig into this book, because the pace at Turing didn’t allow for a few weeks of thinking just about SQL.

I’ve got more time in my life now, and the company I work for makes heavy use of SQL queries, so I’m spending a little time each day working through this book. The following started as a gist, and I’m putting here, so I can more easily share it with others.

Why Study SQL

Pretty much everything on the internet lives in a database. I figure any boost to my SQL skills will provide outsized returns down the road.

For example, just today I used some basic SQL queries to validate an assumption I had about the frequencies of null values in certain places in our database. I wouldn’t have even thought to try that, if I didn’t know in advance what I could do with a basic SQL query.

If you buy this book, and want to get set up with it’s accompanying data on your own computer, so you can practice yourself and follow along with the book… read on.

The friction of getting set up kept me from getting started with this book, and I don’t want that to happen to you too. :)

>> Read more

On Friction

warning. self-indulgeant diatribe coming. I generally try to avoid these, but it’s my website, and I can write what I want.

We’re rapidly approaching the end of the year, and I’ve got a few dozen ideas rolling around my head that I want to solidify my thoughts on.

One of the reasons I write these words on this little corner of the internet is simply to clarify my own thinking on a given topic. I try to not overthink them

This is known as rubber duck debugging and I’ve found it to be enormously effective.

I’ve found myself to be often giving the advice of “write more” to people. One of my favorite past-times is helping people get new/better jobs, and a common thread throughout that process is “write something” or “write more”. But in the same breath as I recommend writing as a means to a better job, I underscore that writing has endless value beyond the fairly transactional purpose of demonstrating competence.

This act (of pen to paper/fingers to keyboard) clarifies your thinking. On anything.

I’ve been resisting writing because much of my attention is unwillingly drawn to things that frustrate me. (Please reference: politics, marketing). The internet certainly doesn’t need another screed about the injustices of {unjust thing}, and I don’t plan to add another one.

>> Read more