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 [...]
Latest articles under Database category
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 9×9 [...]
A lot of times, I saw programmers use COUNT(*) and check if the result is greater than 0 to see if a particular record exits in a table. If your only purpose is to know if a record exists or not and you don’t really care about how many matched records are there, the better [...]
There are times when you want to alter schema for all tables in the database. For example, let’s say in your project you have multiple databases with multiple tables on each of them. Suppose that you have columns within that table defined as DECIMAL(11,6). What it means is that the column will have 11 digits [...]
One of the golden rule of programming is to know about the function you are calling. You need to know what parameters it takes and what return values and type it gives back. For the most part, it’s not too hard to find that out. For MySQL, however, I found that it’s not always easy [...]