php操作数据库看到og.id 、og.orderid=:orderid、g on g.id,是什么意思

php中文网
发布: 2016-06-23 13:15:10
原创
1827人浏览过

pdo_fetchall("select og.id,og.realprice,og.total,g.hascommission,g.nocommission, g.commission1_rate,g.commission1_pay,g.commission2_rate,g.commission2_pay,g.commission3_rate,g.commission3_pay from " . tablename(shop_order_goods') . '  og ' . ' left join ' . tablename('shop_goods') . ' g on g.id = og.goodsid' . ' where og.orderid=:orderid and og.uniacid=:uniacid', array(
                ':orderid' => $orderid,

每个字段前面都加了og.如og.id,og.realprice,这什么意思

数据库中有id和goodsid字段,但是g on g.id这种形式是什么意思。

还有 og.uniacid=:uniacid这种og.以及等号后面的:冒号是什么意思

阿里云-虚拟数字人
阿里云-虚拟数字人

阿里云-虚拟数字人是什么? ...

阿里云-虚拟数字人 2
查看详情 阿里云-虚拟数字人


回复讨论(解决方案)

XXX.xxx XXX 是别名

:uniacid 是参数化传参是的参数名

XXX.xxx XXX 是别名

:uniacid 是参数化传参是的参数名


别名是随便命名的是吗?这个别名是做什么用的,跟直接使用字段的区别在哪里?

g on g.id这种形式是什么意思。点前面还有字母和空格又加字母

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ;  这里abc就是数据库名。

对于你的
...  from " . tablename(shop_order_goods') . '  og ' . ' left join ' . tablename('shop_goods') . ' g ...
tablename(shop_order_goods') 和 tablename('shop_goods') 返回的是表名,可见并不是确定的值
而关联表达式 on g.id = og.goodsid 中,如果 g 和 og 不使用别名的话,就有得调用那两个函数,显得很臃肿了

og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ;  这里abc就是数据库名。


别名的意义是什么?


og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ;  这里abc就是数据库名。


别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select  information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;



og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ;  这里abc就是数据库名。


别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select  information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;
join加载了完成的数据库,然后其他调用数据库就可以使用别名是吗?



og可能是别名,也可能是数据库名。
例如
select * from member as a where a.uid=1; 这里a就是member的别名

select * from abc.member ;  这里abc就是数据库名。


别名的意义是什么?

可以写得短一些。

例如你表名是information_schema_member和information_abc,需要join

不使用别名
select  information_schema_member.name,information_abc.addtime from information_schema_member join information_abc on information_schema_member.id=information_abc.uid;

使用别名
select a.name,b.addtime from information_schema_member as a join information_abc as b on a.id=b.uid;
看来确实如此,谢谢了
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号