Tag Archives: sql

More nifty SQL: insert if not exists

Quite often you want to insert a record into a table, but only if it doesn’t already exist. OK, you could first do a SELECT query to check for existence, and then do the insert, but it’s clumsy and raises … Continue reading

Posted in Databases | Tagged , | Leave a comment

ADODB database abstraction library for PHP

I’ve been using this library for years to make my database interface code database-independent, but I am still discovering new useful functions. Case in point: today I was using the handy rs2csv function, which outputs a recordset to a CSV … Continue reading

Posted in Databases, PHP, Web development | Tagged , | Leave a comment

SQL query to find duplicate rows

This is one of those things I can never remember how to do when I need to do it. I don’t know why, it’s really quite simple: SELECT emailaddress, firstname, lastname, COUNT(emailaddress) FROM customers GROUP BY emailaddress HAVING COUNT(emailaddress) > … Continue reading

Posted in Databases | Tagged , | Leave a comment

Another handy SQL Server utility

Why doesn’t SQL Server come with a built-in method for generating SQL dump files so you can easily port your data to another database? Microsoft in its own little walled garden I suppose; while the facilities in Enterprise Manager for … Continue reading

Posted in Databases, Web development | Tagged , | Leave a comment

SQSH!

About the only reason I ever boot into Windows on the spare PC nowadays is because I need to use Enterprise Manager or Query Analyser to manage a SQL Server database. Today it was inconvenient to reboot, because I was … Continue reading

Posted in Databases | Tagged , | Leave a comment

Neat tricks with Oracle

The task: provide a neat hierarchical tree as a web interface to a project management system where any project might have a variable number of sub-projects. A tree structure in other words. So I ended up with this: ID Project … Continue reading

Posted in Databases, Javascript, PHP, Web development | Tagged , | Leave a comment