这个sql如何关联2张表

WBOY
Release: 2016-06-23 14:05:31
Original
957 people have browsed it

原sql语句为:
SELECT *  from ( SELECT DISTINCT *, year( from_unixtime(time ) ) year, month( from_unixtime(time ) ) month FROM A表 WHERE id = 1) as a WHERE  is_del =0 AND year = 1 AND month = 1 order by time DESC

现在我想关联B表.如何查询?
A表.id=B表.id


回复讨论(解决方案)

SELECT *  from ( SELECT DISTINCT *, year( from_unixtime(time ) ) year, month( from_unixtime(time ) ) month FROM A表 WHERE id = 1) as a , B表 b WHERE  a.id=b.ai and is_del =0 AND year = 1 AND month = 1 order by time DESC

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template