Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 个表)
本文介绍了在 SELECT(MYSQL/PHP) 中加入 2 个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这两张桌子.连接密钥"是两个表中都包含的 conID.所以现在我想写一个 select 语句,它会给我这样的东西:
I have these two tables. The connecting "key" is conID which is included in both tables. So now i would like to write select statement which would give me something like this:
John Smith 乳品 22 Texas 4000 smth4
John Smith dairy22 Texas 4000 smth4
Mike Situation glenn32 Jersey 1000 smth1...
Mike Situation glenn32 Jersey 1000 smth1 ...
>表人":
NUM Name lastName address conID
-----------------------------------------
1 John Smith dairy22 Texas
2 Mike Situation glenn32 Jersey
3 Duke Nukem haris48 NYork
4 Queen Lisa court84 London
>表国家"
conID postNum region
-------------------------
Jersey 1000 smth1
NYork 2000 smth2
London 3000 smth3
Texas 4000 smth4
<强>!-> NUM 是 AUTO INCREMENT 主键,如果可能的话,我不希望它是输出.
提前感谢您的帮助:))
Thanks for help in advance :))
推荐答案
这应该返回您想要的行,基于 num 列:
This should return the rows you want, based on the num column:
SELECT Name, lastName, address, people.conID, postNum, region
FROM people
JOIN countries
ON people.conID = countries.conID
WHERE num=1
这篇关于在 SELECT(MYSQL/PHP) 中加入 2 个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在 SELECT(MYSQL/PHP) 中加入 2 个表
猜你喜欢
- PHP - if 语句中的倒序 2021-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
