本帖最后由 u010250831 于 2013-09-20 00:40:02 编辑
sql as php mysql
以下为zen cart 开源商城系统一条SQL语句!
select distinct p.products_id, p.products_image, p.products_tax_class_id, pd.products_name,
p.products_date_added, p.products_price, p.products_type, p.master_categories_id
from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
where p.products_id = pd.products_id
and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'
and p.products_status = 1 " . $display_limit;
上面的SQL语句中“p”和“pd”都应该是别名!
但是【from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd】这句在定义别名时没有用到As是怎么回事?它是不是别名?还有其他什么可能的用法没?求大神指点!
回复讨论(解决方案)
as是可以不写的。
运行sql的时候,直接输出sql,放在编辑器执行看看就知道了。
as 可写可不写
as看情况,一般可以不写,
不过有些环境配置会要求做Mysql 多表联合嵌套查询时必须加上as
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