我有这两张桌子.连接密钥"是两个表中都包含的 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 个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何使<option selected=“selected">由How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 设置?)
使用 PHP 中的数组自动填充选择框Auto populate a select box using an array in PHP(使用 PHP 中的数组自动填充选择框)
PHP SQL SELECT where like search item with multiple wordsPHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 从 MSSQL-SELECT 产生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(),名称 ASCMySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名称 ASC)
PDO 从数据库中获取数据PDO get data from database(PDO 从数据库中获取数据)