3 개의 테이블이 있습니다.
Table 1: columns are:
+------+-------+----------+----------+
| date | time | user_id | channel |
+------+-------+----------+----------+
Table 2:
+---------+------------+
| user_id | id _number |
+---------+------------+
Table 3:
+---------+-------+
| channel | sort |
+---------+-------+
In table 1 the columns are sorted as following :
2011-07-29, 12:35:15.650, 22, DeluxeMusic
In table 2 :
130.83.10.c42ce82365b9f6d , 22 (same as user_id in table 1)
In table 3:
DeluxeMusic (same as in table 1), entertainment.
열 user_id
에서는 table 2
: 130.83.10.c42ce82365b9f6d
일부 사용자의 USER_ID를 의미한다. 이 사용자 ID 130
에서 시작에 값이 있는 모든 항목을 가져와야합니다. 값이 130 인 모든 항목
그럼 난의 가치를 추구 할 필요가 130
에서 table 3
채널의 종류가보고되며, 모든 사용자가 채널 일반을 보는 것을에 의해 계산.
채널 유형도 다음과 같습니다 sport, shopping, entertainment and so on
..
이것도 시도해 볼 수 있습니다.
select count(*) from t1 join t2 on t1.id = t2.id and t2.userid like '130%' join
t3 on t1.channel = t3.channel group by t1.channel
여기에 SQL 바이올린
편집하다:
다른 버전 :
select count(t1.id) , t1.*, t2.*, t3.*
from t1 join t2 on t1.id = t2.id join
t3 on t1.channel = t3.channel and t2.userid
like '130%' group by t3.channel, t1.id
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다