Home  >  Article  >  Backend Development  >  简单的sql查询语句

简单的sql查询语句

WBOY
WBOYOriginal
2016-06-13 10:17:141158browse

求一个简单的sql查询语句

SQL code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->select cp.*,cpsmallclass.shunxu as cpsmallclass.classorder from cp left join cpsmallclass on cp.smallclassid=cpsmallclass.smallclassid order by cpsmallclass.classorder


就是一个这样的sql查询,从cpsmallclass表里面查询出cpsmallclass的shunxu字段添加到cp表里面。然后按照cpsmallclass里面的shunxu字段进行排序。但是由于cp表里面也有shunxu字段,所以给了个新名字叫做classorder。

应该怎么写?一直报错。

------解决方案--------------------
这样试试:
select cp.*,cpsmallclass.shunxu as cpsmallclass_classorder from cp left join cpsmallclass on cp.smallclassid=cpsmallclass.smallclassid order by cpsmallclass.classorder
------解决方案--------------------
cpsmallclass.shunxu as cpsmallclass.classorder
改为
cpsmallclass.shunxu as classorder
Statement:
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