Home  >  Article  >  Backend Development  >  求问超级简单的数据表查询怎么写?

求问超级简单的数据表查询怎么写?

WBOY
WBOYOriginal
2016-06-23 13:46:591209browse

表A字段:id  title  text

表B 字段:id Aid  

表A的id 存为表B的Aid。

查询出表B的 Aid,然后再通过Aid查询出表A的title  ,直接写出一句SQL,怎么写?


回复讨论(解决方案)

selcet * from A where id IN (select Aid from b);

不知道是不是你想要的。

select B.Aid,A.title from B join A on B.Aid=A.id

我也是大概这么写的,怎么跑不过去呢。再去试试先。

select A.title from A,B where A.id=B.Aid 

多谢 是我自己弄错了  符号的东东防不胜防  哎

PHP查询两张表数据的SQL语句
string sqlSel = "select A.id,A.title,A.text,B.id,B.id,B.Aid from A,B where A.id = B.Aid"
//要显示数据表那个信息就用表名加点带上即可OK;

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