i started learn database mysql im confusing how to manage all tables in one page
i’ve tried datatables but still not like what i want i dont know the keyword for searching in google
all tables always have “visitor_id”
example :
list visitor_id
visitor_id | visitor_ip | visitor_country |
---|---|---|
1 | 192.168.1.122 | SG |
2 | 192.168.1.11 | UK |
3 | 192.168.1.9 | CN |
4 | 192.168.1.89 | UK |
file list with file_id and visitor_id
file_path is null, and visitor_id have 2 file_path
file_id | visitor_id | file_path |
---|---|---|
1 | 1 | /hello.img |
2 | 2 | /p.img |
3 | 3 | |
4 | 4 | /hii.img |
5 | 2 | /hello.img |
i save in the stats tables
look in the stats_file, value is 2 because visitor_id 2 is have two file
and if dont have file, stats_file is 0
stats_id | visitor_id | stats_file |
---|---|---|
1 | 1 | 1 |
2 | 2 | 2 |
3 | 3 | 0 |
4 | 4 | 1 |
so, i want output like
visitor_id 3 is hidden because dont have file
Advertisement
Answer
thanks everybody ,solved using SQL joining related tables
SELECT f.file_id,f.visitor_id,v.visitor_ip,f.file_path,v.visitor_country FROM file AS f LEFT JOIN visitor AS v ON f.visitor_id=v.visitor_id