mysql查询出来的数据用连接_mysql – 使用查询从连接的表中检索数据
我想做的事:
我想檢索有關(guān)客戶(hù)的所有數(shù)據(jù)字段(包括與他相關(guān)的表中的所有數(shù)據(jù)(例如,引用的國(guó)家和數(shù)據(jù)字段的數(shù)據(jù)字段)
我想將我的查詢(xún)作為idUser的參數(shù).
這是我的EER圖:
我嘗試了什么:
SELECT
referralagent.firstName
,referralagent.lastName
,customer.firstName
,customer.lastName
,customer.address
,customer.postcode
,customer.profession
,customer.phoneNumWork
,customer.phoneNumMobile
,customer.phoneNumHome
,country.name
,nationality.name
FROM
customer
INNER JOIN referralagent
ON customer.ReferralAgent_idreferralAgent = referralagent.idReferralAgent
INNER JOIN country
ON customer.countryResidence = country.idCountry
INNER JOIN nationality
ON customer.nationality = nationality.idNationality
WHERE customer.idUser = '7'
問(wèn)題:
我不相信我嘗試過(guò)的是“正確”的東西.在那兒
有沒(méi)有更好的方法呢?
總結(jié)
以上是生活随笔為你收集整理的mysql查询出来的数据用连接_mysql – 使用查询从连接的表中检索数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MySQL入门之存储过程与存储函数
- 下一篇: MySQL入门之创建、修改、删除、查看数