Category: SQL

Running multiple instances of mysql on the same machine

24 August, 2010 (15:33) | Linux, SQL, Programming

There are a lot of ways to run two instances of mysqld on one machine. Generally all you need to do is specify different ports and data directories. The method I describe below is basically to copy the default configuration shipped with Ubuntu Server into a different directory and name everything associated with […]

Protection against SQL injection attacks in PHP.

30 May, 2007 (15:50) | SQL, PHP

Early on PHP had no good methods for escaping SQL, and until recently didn’t support parameterized queries. As a result a lot of documentation covers SQL queries without really addressing the issue, and a lot of older PHP developers are unaware of the enhancements made to prevent this type of attack.
PHP 4.3 introduced mysql_real_escape_string […]

Finding “dead time” in a database of start and end times.

22 May, 2007 (15:28) | Snippets, SQL

The following snippet will find “dead time” (e.g. time where no events are scheduled) in a database:
1 select distinct dateadd(s,-1,starttime) as deadtime,"start" from sometable t where
2 0=(select count(*) from sometable u where u.starttime < t.deadtime and u.endtime > t.deadtime)
3 union all
[…]

How to query accross servers using MS SQL Server.

28 December, 2006 (17:08) | SQL

Sometimes you need to query across servers, even servers of different type such as doing a table join from MySQL to Oracle. I’m going to show you two ways you could do this if you have access to an SQL Server. There are ways to do this with other servers, and there are […]