Hi

Been trying to write a query... I have a table of documents, and a table which registers everytime someone downloads a copy of the document. I want to create a report, in one query, which pulls out each document and counts the views... I thought it woudnt be too tough but have come unstuck...

$sql = "SELECT d.title, d.mktime, COUNT(r.id) FROM documents AS d LEFT JOIN clickreg AS r ON r.docid = d.id"

help please!?!

thanks

Make changes highligted below

$sql = "SELECT d.title, d.mktime, COUNT(r.id) FROM documents AS d LEFT JOIN clickreg AS r ON r.docid = d.id 
[b]group by d.title, d.mktime [/b]"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.