[thelist] mysql query help

Mark Joslyn Mark.Joslyn at SolimarSystems.com
Fri Aug 17 13:18:10 CDT 2007


<snip>
group by username, item

also you can then go ahead and list 'item' in the select list
</snip>


Thank you!

"SELECT username, COUNT(username) AS uCount, item, COUNT(item) AS iCount, date, MAX(date) AS myDate FROM myTable GROUP BY username, item ORDER BY username"

This got me a bit closer, but this query would give me this structure

This gives me the following structure:

Username
  - item (item)
  - number of times accessed (iCount)
  - last date accessed (myDate)

Username
  - item#2 (item)
  - number of times accessed#2 (iCount)
  - last date accessed#2 (myDate)

etc..

How would I get this structure:

Username
  - item
  - number of times accessed
  - last date accessed

  - item#2
  - number of times accessed#2
  - last date accessed#2

Thanks,

markJ





More information about the thelist mailing list