Home >Backend Development >PHP Tutorial >求个PHP,MYSQL关联查询语句,该如何解决
求个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里是如何查询的,请帮帮忙!
------解决方案--------------------
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>