Home  >  Article  >  Backend Development  >  2个表中有相同的字段 怎么办

2个表中有相同的字段 怎么办

WBOY
WBOYOriginal
2016-06-13 12:10:541556browse

2个表中有相同的字段 怎么处理?
比如A里面有name字段,B里面也有name字段,这关联在这起怎么知道取的是那个值呢

------解决思路----------------------
select A.name as a_name,B.name as b_name from A,B where...

有条件自己加上就是了。这样就能区分各自的字段了。
------解决思路----------------------
select A.name as a_name,B.name as b_name from A,B where... 

 $u->a_name;


------解决思路----------------------
字段前面加上“表名.”,用别称更好 alias

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