Edit a MySQL command from the $EDITOR
When using MySQL from the command line, you can get into a pretty long SQL statement, and then realize you wanted to change something. For example, a LEFT JOIN to an INNER JOIN. Well, MySQL has a handy little function for making it easier to edit a long command. Much like the Unix command 'fc', which I've written about before, you can use your defined $EDITOR environment variable to be edit your previous SQL statement. At the MySQL command line:
mysql> \e
This will pop open your defined $EDITOR and allow you to edit the command. After editing, save and quit (:wq for you vim users), and just type a semi-colon (;) and hit enter. It will run whatever command you've written into your editor. Voila!