Archive for the ‘mysql’ category

Show the Top ‘N’ in a group inside an SQL query

June 25th, 2010

I’ve been trying to work out how to produce this for a while as I didnt want PHP to do the calculations and increase the server strain, thankfully after much searching I have come across this very helpful tutorial

http://www.artfulsoftware.com/infotree/queries.php?&bw=1245#104

This allows me to show the top 5 results for each group in my code it looks quite similar to this

SELECT seriesid, comicid, number
FROM (
SELECT seriesid, comicid, number,
IF( @prev <> seriesid, @rownum := 1, @rownum := @rownum+1 ) AS rank,
@prev := seriesid
FROM comic t
JOIN (SELECT @rownum := NULL, @prev := 0) AS r
ORDER BY t.seriesid
) AS tmp
WHERE tmp.rank <= 5
ORDER BY seriesid, number, comicid;

This is an example that I was working on, it shows three columns (seriesid, comicid & number) from the table (comic)

403 Errors in Dreamweaver when trying to connect to a mysql database

June 21st, 2010

Afternoon all,
I’ve just spent the last 3 or so hours trying to solve a particulary annoying issue in Dreamweaver CS4, I wanted to connect to the mysql server using dreamweaver so I can create some code with a little more pollish than my current “nano” work. However each time i tried to fix this I got 403 error from the server. I did some minor work on the permissions (ie 755 chmod access) but nothing worked and then tried this and hey-presto it worked.

chown www-data\: _mmServerScripts/ _mmServerScripts/*
chgrp www-data _mmServerScripts/ _mmServerScripts/*

Obviously the above is valid for my setup and may require some modification for yours but it’s a nice easy fix.