[英]best way database management in php
i started learn database mysql im confusing how to manage all tables in one page我开始学习数据库 mysql 我很困惑如何在一页中管理所有表
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"所有表总是有“visitor_id”
example:例子:
list visitor_id列出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_id 和 visitor_id 的文件列表
file_path is null, and visitor_id have 2 file_path file_path 是 null,visitor_id 有 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查看 stats_file,值为 2,因为 visitor_id 2 有两个文件
and if dont have file, stats_file is 0如果没有文件,stats_file 为 0
stats_id ![]() |
visitor_id![]() |
stats_file ![]() |
---|---|---|
1 ![]() |
1 ![]() |
1 ![]() |
2 ![]() |
2 ![]() |
2 ![]() |
3 ![]() |
3 ![]() |
0 ![]() |
4 ![]() |
4 ![]() |
1 ![]() |
so, i want output like所以,我想要 output 喜欢
visitor_id 3 is hidden because dont have file visitor_id 3 被隐藏,因为没有文件
thanks everybody,solved using SQL joining related tables谢谢大家,使用 SQL 加入相关表解决
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
from https://www.w3schools.com/sql/sql_join_inner.asp来自https://www.w3schools.com/sql/sql_join_inner.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.