我正在爲我的客戶端和頁面之一(用PHP和HTML編寫)的數據庫工作,我需要在其客戶端上顯示所有信息,但是當我運行下面的查詢(假設選擇'family'表中的所有行),它返回總共0行。當它應該返回所有行的表中的SQL查詢不返回預期值
SELECT
families.id AS fam_id,
families.last_name AS fam_surname,
families.address_1 AS fam_address_1,
families.address_2 AS fam_address_2,
families.city_id AS fam_city,
families.phone AS fam_phone,
families.mobile AS fam_mobile,
families.email AS fam_email,
families.f_d_worker_1 AS fam_fdw_1,
families.f_d_worker_2 AS fam_fdw_2,
families.status_id AS fam_status_id,
families.trans_date AS fam_trans_date,
families.entry_date AS fam_entry_date,
families.exit_date AS fam_exit_date,
families.eligible_date AS fam_eligible_date,
families.active_date AS fam_active_date,
families.lga_loc_id AS fam_lga_id,
families.facs_loc_id AS fam_facs_id,
families.ind_status_id AS fam_indig_id,
families.referral_id AS fam_ref_id,
families.active_status AS fam_act_status,
families.comm_org_id AS fam_com_org,
city.id AS city_id,
city.name AS city_name,
city.state_id AS city_state,
city.post_code AS post_code,
states.id AS state_id,
states.long_name AS state_name,
states.abbrev AS state_abbrev,
client_status.id AS client_stat_id,
client_status.name AS client_stat_name,
community_org.id AS com_org_id,
community_org.name AS com_org_name,
facs_location.id AS facs_id,
facs_location.name AS facs_name,
lga_location.id AS lga_id,
lga_location.name as lga_name,
indig_status.id AS indig_id,
indig_status.name AS indig_name,
referrals.id AS ref_id,
referrals.name AS ref_name,
f_d_workers.id AS fdw_id,
f_d_workers.first_name AS fdw_first_name,
f_d_workers.last_name AS fdw_last_name,
client_status.id AS client_id,
client_status.name AS client_name
FROM
`families`,
`city`,
`client_status`,
`community_org`,
`facs_location`,
`f_d_workers`,
`indig_status`,
`lga_location`,
`referrals`,
`states`
WHERE
families.city_id = city.id AND
families.f_d_worker_1 = f_d_workers.id AND
families.f_d_worker_2 = f_d_workers.id AND
families.status_id = client_status.id AND
families.lga_loc_id = lga_location.id AND
families.facs_loc_id = facs_location.id AND
families.ind_status_id = indig_status.id AND
families.referral_id = referrals.id AND
families.comm_org_id = community_org.id
你真的應該使用'INNER JOIN'來做這個... – hichris123
@ hichris123我對INNER JOIN函數沒有任何經驗,並且有一點研究我沒有看到它適合我的情況。請您詳細說明如何使用它? –