我需要创建一个从同一个数据库中的三个表中读取的单个查询。
表:
1. cm_players
player_id
card_no
club_id
surname
name
birthdate
2. cm_clubs
club_id
prefix
name
address
place
stadium_id
telephone
fax
email
web
contact_person
president
secretary
press_officer
status
image
3. cm_registrations
player_id
surname
name
birthdate
birthplace
club_id
date_from
date_to
amateur
status
所以,我需要显示
cm_players.name,
cm_players.surname,
cm_clubs.name,
cm_players.birthdate,
cm_players.card_no,
加入 cm_players 和 cm_clubs 以获取俱乐部的名称,如果用户处于活动状态,则检查 cm_registrations .....
我试过类似的东西:
SELECT cm_players.name, cm_players.surname, cm_clubs.name, cm_players.birthdate, cm_players.card_no, cm_registrations.amateur FROM cm_players
INNER JOIN cm_clubs on cm_players.club_id = cm_clubs.club_id, cm_registrations
WHERE cm_players.name LIKE '%$name%' AND cm_players.surname LIKE '%$surname%' AND cm_players.player_id = cm_registrations.player_id AND cm_registrations.amateur = 0 ORDER BY cm_players.player_id ASC
但没有运气...
谁能帮我建立这个查询?