本文介紹了在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我有這兩張桌子.連接密鑰"是兩個(gè)表中都包含的 conID.所以現(xiàn)在我想寫一個(gè) select 語(yǔ)句,它會(huì)給我這樣的東西:
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
>表國(guó)家"
conID postNum region
-------------------------
Jersey 1000 smth1
NYork 2000 smth2
London 3000 smth3
Texas 4000 smth4
<強(qiáng)>!-> NUM 是 AUTO INCREMENT 主鍵,如果可能的話,我不希望它是輸出.
提前感謝您的幫助:))
Thanks for help in advance :))
推薦答案
這應(yīng)該返回您想要的行,基于 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
這篇關(guān)于在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!