Forum Moderators: open

Message Too Old, No Replies

Select the count of distinct URLs from two table

         

dertyfern

12:41 pm on Sep 4, 2009 (gmt 0)

10+ Year Member



Have two mysql tables:

1. tbl_files
2. tbl_logs

a. tbl_files contains a list of distinct URLs of a website
b. tbl_logs contains daily logs files for same website

I'm trying to figure out how write a script that will:
1. use value of tbl_files to select the count the same value from tbl_logs
2. go to next record of tbl_file
3. repeat step 1

So starting and the beginning of tbl_files through to the end.

Any help would be appreciated.

Demaestro

2:20 pm on Sep 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Something like this?

SELECT
tbl_files.URL, count(tbl_logs.URL) as total_url
FROM
tbl_files
LEFT JOIN
tbl_logs on tbl_files.URL = tbl_logs.URL
GROUP BY
tbl_logs.URL
SORT BY
tbl_files.URL

Since I don't know your column name I made one up called URL.

dertyfern

9:45 am on Sep 5, 2009 (gmt 0)

10+ Year Member



Thanks. I'll play around with it.

Demaestro

3:30 pm on Sep 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you have more questions feel free to ask