Home > Database > Mysql Tutorial > mysql-MYSQL 两个表联合查询 比较绕

mysql-MYSQL 两个表联合查询 比较绕

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 09:33:47
Original
1042 people have browsed it

mysql

表一
ID 基本信息 详细信息
1 张三 张三
2 李四 李四
3 王五 王五
4 老六 老六
表二
ID 详情 修改日期
1 买了个鸡蛋 20160101
1 住院了 20160102
2 死了 20160101
2 又活了 20160102

我想要的结果是查询出ID为1的最新状态,然后结合表一返回一条结果
ID 基本信息 详细信息 详情 修改日期
1 张三 张三 住院了 20160102

我的原始表中表一是基本信息,表二的信息经常更新的(同时用在历史状态搜索
),我想要一条语言搜出对应ID的最新状态,如果放在一个表里面的话,表一会变得很大

非常感谢!

补充一下
表一是主表 表一id为主键 表二的id是外键 表二另外有一个自己的主键

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template