#PHPUK2010 Part 2 (MySQL stuff) - wade.one
Just picked up a nice tid-bit on creating a unique index on a two column table where the values in each column may be either way around but you only ever want one instance of the value in that row. So what this means is, inserting 2,1 and 1,2 for example would result in only the first of the two inserts succeeding. CREATE UNIQUE INDEX ON tablename (LEAST(col1,col2), GREATEST(col1,col2)); Also, WITH, I’ll be honest, never thought about using it to create temporary views. This is a bad example but shows the structure rather well: WITH tempView (a,b) AS ( SELECT … Continue reading →