If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Can’t count how users and pages in the tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-11-05, 03:04
ramis55 ramis55 is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
Can’t count how users and pages in the tables

Hello
I’m having two tables ap_user and read_page. I want write query that returns how user is logged from ip address and how pages read from ip addres. In table read_page one record is one page readied.
ap_user-------------------------
| user_id | ip | device_model |
| 1 | 195.14.172.97 | Nokia3510i |
| 2 | 195.14.172.97 | Nokia7650 |
| 3 | 194.176.32.169 | SIE-SX1 |
| 4 | 195.14.172.97 | Nokia7650 |

read_page------------------
| date | user_id | page_id |
| 2005-01-07 | 1 | 1 |
| 2005-01-07 | 1 | 8 |
| 2005-01-07 | 2 | 3 |
| 2005-01-07 | 1 | 4 |
| 2005-01-08 | 3 | 9 |
| 2005-01-08 | 1 | 5 |
When using the second query get how users are logged from ip. SELECT ap_user.ip, COUNT(ap_user.user_id), FROM ap_user GROUP BY ap_user.ip
But when execute second query returns only good data how pages readied from ip and bad data how users are logged from ip.
SELECT ap_user.ip, COUNT(ap_user.user_id), COUNT(read_page.page_id) FROM ap_user LEFT JOIN read_page USING(user_id) GROUP BY ap_user.ip

Maybe can write good query, that can get how user is logged from ip address and how pages read from ip address? Please!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On