Author: Kevin Lawver

  • I Don’t Know an Alias From A Join In The Ground

    In the spirit of learning something new every day (and the fact that the way I was doing it took 20 minutes each time I ran the query), I learned how to select aliased tables with Postgres today. For those of you who aren’t geeky, you may want to skip this post altogether.

    I’ve been using SQL when I had to for almost five years now and never run into a spot where I’d do something like this, but it worked really really well and runs a whole lot faster than the old way (mostly because I was doing a JOIN of a table with almost a million records to one with 250k records).

    I know the suspense is killing you… how do you do it? This example is completely unrelated to what I’m actually using it for, because it’s work related. Let’s say you have a table full of used car ads and you want to get each distinct manufacturer and how many ads there are for each of those manufacturers. Now, if you have a separate table of car makers, this is fairly easy. But, let’s (for sake of my precious example) say manufacturer is a free text field where the user can enter whatever they want. To get out the list of manufacturers and the number of cars ordered by most often listed, you could do the following:

    select distinct lower(manufacturer) as carmaker,(select count(*) from car_ads where manufacturer = carmaker) as car_count from (select lower(manufacturer) from $table where timestamp between $begin and $end) as all_ads order by car_count desc,carmaker

    How cool is that? You can create a virtual table with a select statement from either the same table or a separate one. You could even join your virtual table with another virtual table for even MORE fun!

  • I’m Related to Who?

    Who are you related to? I’m just thrilled I’m related to Jodi.

  • It’s Nice to Be Needed

    It’s always nice to come in first thing Monday morning to almost 100 pieces of e-mail in my inbox. And that’s AFTER going through about 50 on Saturday afternoon. It’s nice to be needed.

    In other news that’s completely unrelated, I am about to be 5-0 in Fantasy Football. My team doesn’t score the most points, but it does a good job of playing up to the competition. As long as Jim Miller doesn’t blow it, and Ahman Green doesn’t go nuts, I’m safe (I have a 40 point lead going into tonight’s game).

    It makes me wish I put money in the pool.

  • That’s One Creepy Hippo

    Browsing around the Mirror Project, I came across this site, which has the creepiest photo of a hippo I’ve ever seen. Great shot.

  • Birthday Photos

    So, my submission to The Mirror Project was accepted. I’m really happy with the picture and how it turned out.

    In other photographic news, Max’s birthday pics are up! We had a great time, and better yet, Max had a ball. We watched Monsters Inc., played around a lot and had a lot of fun. We let Max stay up late and he slept in until almost NINE this morning.

    I’m still recovering…

  • Obsessive Parents Unite!

    In the spirit of documentation, here are even more pictures! As a little birthday treat, we took Max to Chuck E. Cheese. I’m not sure who had more fun.

  • Photographic Evidence

    I told you about it before, now I have photographic evidence to share. Today, my son turns three. Three years ago we were in the hospital, nervous, full of anticipation and ready to welcome him into the world. I love him more than I can say, and his mother more than I’ll ever be able to express. Happy birthday, little man!

  • ::POP::

    This poll from CNN disturbs me. I had a big long post about why, but I couldn’t get out what I really want to say, so you look at it and tell me what you think.

  • Five… Four… Three… Two… One… BLASTOFF!!

    Max got his hair cut today. Jen took him in, and in the heat of the moment had them cut off almost all his hair! He has a quarter of an inch left all around (or less). It’s really cute, but makes him look so much older! He already looks like he’s four, but the hair makes him look like he belongs in Kindergarten. Then, he opens his mouth and out comes his practically (Friday) three year-old babble and that makes it that much cuter!

    Jen had a thing at church tonight, so Max and I played. We played rocketship on our bed. Max steered and provided the countdown while I provided the rumbly rocket noises, status updates and turbulence. It was hilarious. Then, we played Leap-Daddy, came downstairs and played Jak and Daxter, changed a diaper, read a story, tucked him in and came downstairs. He’s so much fun.

  • Geek Tip of the Day

    If you create a database, don’t expect it to live forever. Always keep a backup of at least your schema, and preferrably your data. After having experienced a total data loss, I’m at least reassured that I kept my schema on a system other than the one the database was running on. I had to recreate all my tables and indexes, but thankfully I’d saved them offline and it was as simple as cutting and pasting. Now, if only I had backed up my data…