Category Archives: Database
Default to utf8 encoding for MySQL 5.5
Been banging my head several times trying to set the correct configuration for setting utf8 as default encoding for my MySQL database. Searching the web shows old configuration that is not compatible with MySQL 5.5. However, I’ve found one that … Continue reading
SQL Server – Generating Date Range With CTE
My job was to create a report for monthly totals of a specific year. It will compute monthly totals from April 1 of that year to March 31 of the next year and must return exactly 12 rows for that … Continue reading
SQL Server – Using Temporary Tables
The original query was almost perfect – it displays the daily totals for a given month. However, specs changed and they need to add the grand total to the last row. Then another specs for the MAX and MIN rows. … Continue reading
SQL Server – Dynamic Order By Clause
Yes, I’m too busy for SQL scripting job these recent weeks. I have a union select query that needed to be sorted per union but since it is not allowed to have order by in my unions, I have to … Continue reading
SQL Server Import/Export to CSV
There are tools that will help you in importing or exporting CSV files to and from SQL Server databases. However, using them will slow you down for a factor of 20 because of those click, next, next, next wizard thing. … Continue reading
SQL Server – Select Nth Row
Seems like I’m now stuck with .NET development and the current tasks where developing SQL scripts. One of the spec was to return the first record, second record and third record as columns for a row. I know how to … Continue reading
SQL Server – Dynamic Where Clause
Things can be neatly done in application level by concatenating where clause however, there are times when you are out of that application and all you can do is SQL Query. I have found a good resource to do so … Continue reading
PHP and PostgreSQL on Windows
PostgreSQL is now easy to install on Windows using its installer. However, integrating it with PHP in Windows usually has problems. No matter how you configure PHP and the DLL for postgres extension, it will not work out of the … Continue reading
Changing URL – WordPress and Moving to a new domain
If you have a blog that is up for few years already and suddenly you decided to move to a new domain / url, you end up changing all the link from config, to post contents and to comments. Using … Continue reading
Updating Multiple Rows in MySQL
There comes a time when you need to update multiple rows with different values. You can update multiple rows with the same value, but when dealing with different values for different rows, it becomes a difficult task. Yes there are … Continue reading




