php 中的最佳数据库管理方式

best way database management in php

我开始学习数据库mysql 我很困惑如何在一页中管理所有表格

我试过数据表,但还是不喜欢我想要的 我不知道在 google

中搜索的关键字

所有表格总是有“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_id 和 visitor_id

的文件列表

file_path为空,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

我保存在统计表中

查看stats_file,值为2 因为visitor_id 2 有两个文件

如果没有文件,stats_file 是 0

stats_id visitor_id stats_file
1 1 1
2 2 2
3 3 0
4 4 1

所以,我想要像

这样的输出

this

visitor_id 3 被隐藏因为没有文件

谢谢大家 ,使用 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

来自 https://www.w3schools.com/sql/sql_join_inner.asp