我只想显示活动用户的供应商地址。下面是系统的数据库。
就像我上面提到的,我只想显示活动供应商的供应商地址。上面提供的图像显示了 A-供应商地址表和 B-status_login表,其中包含“活动” 元素。
现在,我的编码如下:
$activeSupplier = "Active";
// fetch data for 'ACTIVE' Supplier Basic Info Table from table (supplier_profile)
$supplierAddressInfoListTable = SupplierAddress::find()
->select(['supplier_address.supplier_addressID AS supplierAddressID', `
'supplier_address.supplier_profile_ID AS supplierID', 'supplier_address.address_one AS supplierAddressone',`
'supplier_address.address_two AS supplierAddresstwo', 'supplier_address.postcode AS supplierPostcode',
'supplier_address.city AS supplierCity', 'status_login.description AS supplierLoginstatus',
'state.stateID AS supplierStateID', 'state.name AS supplierStatename',
'country.countryID AS supplierCountryID', 'country.name AS supplierCountryname'])
->leftJoin('supplier_profile', 'supplier_profile.supplier_profileID = supplier_address.supplier_profile_ID')
->leftJoin('state', 'state.stateID = supplier_address.state_ID')
->leftJoin('country', 'country.countryID = supplier_address.country_ID')
->where(['=', 'status_login.description', $activeSupplier])
->orderBy(['supplier_profile.supplier_profileID' => SORT_ASC])
->asArray()
->all();
我不知道如何不必依靠临时表来获得收益。如果您有任何建议,请在此推荐。
答案 0 :(得分:0)
此外,您还需要加入login_profile和status_login表。
`
$activeSupplier = "Active";
// fetch data for 'ACTIVE' Supplier Basic Info Table from table (supplier_profile)
$supplierAddressInfoListTable = SupplierAddress::find()
->select(['supplier_address.supplier_addressID AS supplierAddressID', `
'supplier_address.supplier_profile_ID AS supplierID', 'supplier_address.address_one AS supplierAddressone',`
'supplier_address.address_two AS supplierAddresstwo', 'supplier_address.postcode AS supplierPostcode',
'supplier_address.city AS supplierCity', 'status_login.description AS supplierLoginstatus',
'state.stateID AS supplierStateID', 'state.name AS supplierStatename',
'country.countryID AS supplierCountryID', 'country.name AS supplierCountryname'])
->leftJoin('supplier_profile', 'supplier_profile.supplier_profileID =
supplier_address.supplier_profile_ID')
->leftJoin('login_profile', 'supplier_profile.supplier_profileID =
login_profile.supplier_profile_ID')
->leftJoin('status_login', 'login_profile.status_login_ID =
status_login.status_login_ID')
->leftJoin('state', 'state.stateID = supplier_address.state_ID')
->leftJoin('country', 'country.countryID = supplier_address.country_ID')
->where(['=', 'status_login.description', $activeSupplier])
->orderBy(['supplier_profile.supplier_profileID' => SORT_ASC])
->asArray()
->all()
`