Here is my query:
query2 = "
INSERT INTO randomnusers
SELECT src_ip, vlan_id, video_id, area
from video_2
WHERE date_pl >= '2011-11-29 00:00' AND date_pl <= '2011-12-05 23:55'
as table1 right join (SELECT distinct src_ip, vlan_id
from video_2
WHERE date_pl >= '2011-11-29 00:00'
AND date_pl <= '2011-12-05 23:55'
order by rand() limit 50)
as table2 on table1.src_ip = table2.src_ip, table1.vlan_id = table2.vlan_id"
In video_2 table, each users (use the combination of src_ip and vlan_id to identify different users) have several entries about their downloading history.
Now I want to randomly choose 50 different users, list all their downloading history in a new table called randomnusers.
But this syntax has an error around “as table1” can anyone help me to check?
Many thanks
The syntax of
SELECTstatement isSELECT t1.name, t2.salary FROM employee AS t1, info AS t2 WHERE t1.name = t2.name;