SQL JOINing a Table to Itself

Getting two sets of information from one table in a select statement often leads people to write subselects, but it really doesn’t matter that this is the same table twice, we can just give it a new alias and treat it as if it were a different table. This is one of those techniques where, once you’ve seen it, it’s really obvious, but until that point it can be very confusing. I explained this to someone else recently, so I thought I’d capture it here in case it’s helpful to anyone else.

Consider that tried-and-tested example: employees and managers. Here’s the staff table from the database (today’s imaginary data isn’t particularly imaginative, sorry):

mysql> select * from staff;
+----+------------+-----------+------------+
| id | first_name | last_name | manager_id |
+----+------------+-----------+------------+
|  1 | Hattie     | Hopkins   |          4 |
|  2 | Henry      | Hopkins   |          4 |
|  3 | Harry      | Hopkins   |          5 |
|  4 | Helen      | Hopkins   |       NULL |
|  5 | Heidi      | Hopkins   |          4 |
|  6 | Hazel      | Hopkins   |          1 |
+----+------------+-----------+------------+
6 rows in set (0.00 sec)

Continue reading

5 Things To Do With A Training Budget of Zero

Training budgets are never generous enough to give us everything we think we need to keep our skill sets improving, however many people will be lucky enough to get something. If your training budget totals precisely zero pounds (or euros, or dollars, or whatever your local currency is), what do you do? Sulk until they give you something more? Or make the most of what you have? Continue reading

Ideas of March: Write and Read

Today you may see a few folk dusting off their blogs to celebrate “Ideas of March” where we blog about blogging and pledge our good intentions to blog for another year. Personally, I think I blog more than enough already, but I’ve been thinking recently about writing, ideas and how important two-way knowledge exchange is. Continue reading

Speaking at Leeds PHP

On Monday 19th March I’ll be speaking at PHP Leeds. The topic is all things git and github; as an open source project lead I see lots of very capable programmers taking their first steps with github. In this session we’ll talk about how you can use these tools to contribute to open source (or your own projects, of course), covering both “what to click in the web interface” and “what to type at the command line” for git and github respectively. Come along if you want to know more about git, open source, or github!

Generating Callgraph with XHGUI

I had a frustrating bug the other day with a new XHGUI install, I am working on creating a VM for my new PHP tools course I am teaching in March and I wanted to pre-install and part-install a bunch of things so that I can show some great tools in a limited amount of time. My XHGUI wasn’t quite right though; it couldn’t generate the callgraph for me. Instead, it said:

failed to shell execute cmd=" "" -Tpng"

Continue reading

Thoughts on Running an Open Source Project

I spoke in the unconference at PHPUK last week, on running an open source project. I thought I would collect together my thoughts into one place before I lose the scratty piece of paper I wrote them down on. I’m not sure I’m the right person to be giving advice exactly, but these are the things that, having been project lead on joind.in for a while, I think are important.
Continue reading

A Freemium Business Model

I have an android smartphone, and I have *very* few paid for applications on it. Mostly I have document viewers, the wordpress app, mail/calendar/map from google, and so on – plus a couple of free games. In January I downloaded a new game and I’ve been playing it pretty regularly since*.

Tapfish is a game where you can buy, raise and sell fish – like a tamagotchi, all grown up and moved to the smartphone platform (and prettier!) You can play quite a bit of the game without paying for anything – so much in fact that I got quite into it. When you consider that I’ve played daily for 6 weeks, 10 quid for the add-ons that will let me play more of the game seems reasonable. Continue reading

Wedding Stationery

In case you missed it, ours was a small wedding – which means that the majority of our friends and family weren’t actually there! We loved our small wedding but I knew that I still wanted to share a small flavour of the day with some of those friends and family, and also get some mementos for our home.

When browsing the moo.com site (it is usually best to hide all payment cards out of reach before doing this!) I had seen the postcards that they make and decided this would be a great way to send a small selection of photos to a few people. Once we got the “official” photos in, I ordered some postcards, and I think they turned out rather well!

Wedding Postcards
Continue reading