Latest articles under PostgreSQL category

Swap values in 2 rows SQL

I encountered a situation at work that I feel would be a good brain teaser. I was working on a project and needed a way to swap values from 2 different rows in a SQL table. Obviously I can do it on client side (like PHP) to do it; but that wouldn’t be a good […]

Posted on October 11th, 2009 under General SQL, MySQL, PostgreSQL  •  16 Comments

Solving sudoku using PostgreSQL PL/pgSQL

I have no idea why I would want to solve sudoku in PostgreSQL PL/pgSQL. My guess would be just for the fun of it. I’m also hoping that it can serve as a tutorial example in programming PostgreSQL PL/pgSQL. So what is sudoku? It is basically a number puzzle where the objective is to fill […]

Posted on August 19th, 2009 under General / Algorithm, PostgreSQL  •  4 Comments

Comparing data from 2 database tables

During development cycle, I often come to a case where I need to compare two tables whether they are the same or not. For example, if you already have a running script that outputs to a database table in production that was written sub-optimally and you need to improve it. You want to make sure […]

Posted on March 1st, 2009 under General SQL, MySQL, PostgreSQL  •  6 Comments

Floyd-Warshal algorithm in PostgreSQL PL/pgSQL.

This article is an extension of my previous article . This time, however, I will write the algorithm completely in PostgreSQL’s PL/pgSQL. For background information and to understand the premise of this post, please glance through my previous post. Ok now that you’re familiar with what we’re working towards, here’s my assumption of your database […]

Posted on January 24th, 2009 under General / Algorithm, PostgreSQL, Programming  •  1 Comment