Home > Backend Development > PHP Tutorial > 求个PHP,MYSQL关联查询语句,该如何解决

求个PHP,MYSQL关联查询语句,该如何解决

WBOY
Release: 2016-06-13 13:46:46
Original
850 people have browsed it

求个PHP,MYSQL关联查询语句
Article表: ID, ClassID, Title
Class表: ClassID, ClassName
要求查询Article表时根据ClassID的值从Class表中取出ClassName
像MSSQL里的 select (select classname from table_b where classid=table_a.classid), * from table_a
不知道MYSQL里是如何查询的,请帮帮忙!

------解决方案--------------------

SQL code
selete Article.ClassID,Class.ClassID,Class.ClassName as AClassName from rticle,Class where Article.ClassID=Class.ClassID
<br><font color="#e78608">------解决方案--------------------</font><br>SQL code<br>select Article.ID Class.ClassName Article.Title from Article inner join Class on (Article.ClassID=Class.ClassID)<br> <div class="clear">
                 
              
              
        
            </div>
Copy after login
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