Helping you solve those tough coding problems!
Learn some great web development and web design tips and techniques through recipes that clearly define the problem being solved with a working solution.
Popular Tags: cakephp | theory | optimization | javascript-development | css | asp-net | jquery-development | ajax | sql | php-development

Search:
Follow @endyourif rss Facebook LinkedIn

Delete duplicate rows with MySQL or MSSQL Delete duplicate rows with MySQL or MSSQL

Published on Feb 27, 2019 by Jamie Munro

The following article will provide a single SQL query that will delete rows that are duplicated in your table. Before you begin, be sure you've tracked down the bad code that is causing this; otherwise, you will need to run it multiple times!

To start, I will create a basic table structure that will help understand the SQL query:

Read more >

Tags: SQL | mysql | delete | mssql

Concatenate Multiple Rows From a Table Into One Field with MySQL Concatenate Multiple Rows From a Table Into One Field with MySQL

Published on Feb 17, 2019 by Jamie Munro

When you want to merge multiple rows from a table into one field separated by a specific character using MySQL.

By utilizing the existing GROUP_CONCAT function with MySQL, you can easily group multiple rows together into a single field result.

Read more >

Tags: SQL | mysql | GROUP_CONCAT

MySQL: OR versus UNION – which is faster? MySQL: OR versus UNION – which is faster?

Published on Mar 24, 2014 by Jamie Munro

I must say, this came as a shock to me, until I looked at the results and thought about it for a minute.  Before jumping in, let me explain how and where I encountered this.  I was recently working on a project called Deja Scene – The actor to actor movie database.  The purpose of this site is to find two actors who have starred in multiple movies together.

Because the nature of the algorithm an actor can be either on the left side of the connection or the right side.

Let’s look at an example, if I search for George Clooney, I will find that he has 372 Deja Scene connections.  Here was the original query I used to retrieve the list of his connections:



SELECT *

FROM  `actor2_actors`

WHERE actor1_id =1

OR actor2_id =1



Seems pretty straight forward; however, I was seeing really slow performance and I couldn’t figure out why.  I created an index on both the actor1_id and the actor2_id, so I assumed Mysql was properly indexing this.  Boy was I wrong.  Look at the results when I use the EXPLAIN function:

Read more >

Tags: SQL | Optimization | performance | mysql

Setting Up CakePHP with IIS Setting Up CakePHP with IIS

Published on Jun 11, 2013 by Jamie Munro

I’ve found myself doing this several times over the past little while as I had to switch computers.  Each time I would struggle with a few of the steps, so I thought I would document them this time and share for future me (or you if you like).

Read more >

Tags: CakePHP | php | PHP | mysql | iis | CakePHP

Mysql: Insert or Update in One SQL Statement Mysql: Insert or Update in One SQL Statement

Published on Oct 3, 2012 by Jamie Munro

I must say, I really wish I knew about this technique years ago – before I started using frameworks to do a lot of my development.  The effort that was wasted in building separate code and separate logic to deal with inserts vs updates, when all of this time, there is a nice and simple feature built-in to Mysql that does this for us…

Read more >

Tags: SQL | mysql | insert | update | duplicate

Regular Expressions with Mysql Regular Expressions with Mysql

Published on Oct 2, 2012 by Jamie Munro

Mysql Uptime Check Script Mysql Uptime Check Script

Published on Oct 1, 2012 by Jamie Munro

Renaming a Database in Mysql Renaming a Database in Mysql

Published on Sep 28, 2012 by Jamie Munro

Load Testing Mysql with mysqlslap Load Testing Mysql with mysqlslap

Published on Sep 17, 2012 by Jamie Munro

Update: It Actually Should Be LEPP Not LEMP or LAMP! Update: It Actually Should Be LEPP Not LEMP or LAMP!

Published on Sep 14, 2012 by Jamie Munro