反向INNER JOIN?

时间:2015-08-14 16:58:26

标签: php mysql

我正在为当地足球队创建一个网站。要查看匹配,我正在使用2个表vid。团队(团队的所有信息)和比赛 要概述所有匹配项,请使用此查询:

SELECT matches.matchid, CONCAT( ELT( DAYOFWEEK( matches.matchdate ) ,'zon', 'maa', 'din', 'woe', 'don', 'vrij', 'zat' ) , ' ', 
DAYOFMONTH( matches.matchdate ) , ' ', 
ELT( MONTH( matches.matchdate ) , 'jan', 'feb', 'maa', 'apr', 'mei','jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec' ) ,' ',
year( matches.matchdate )
) AS datum_NL, TIME_FORMAT( matches.matchtime, '%H:%i' ) AS UUR  
matches.matchtype, matches.division, matches.season, teams.teamname AS thuisploeg, teamhomescore.teamname AS bezoekers, matches.homescore, matches.awayscore, matches.matchday

FROM teams AS teamhomescore
INNER JOIN (teams
JOIN matches ON teams.teamid = matches.teamhome) ON teamhomescore.teamid = matches.teamaway
ORDER BY matches.matchdate

要在我的editform中获取数据,我使用下一个查询:

SELECT matches.matchid, CONCAT( ELT( DAYOFWEEK( matches.matchdate ) , 'zon', 'maa', 'din', 'woe', 'don', 'vrij', 'zat' ) , ' ', 
DAYOFMONTH( matches.matchdate ) ,
 ' ', 
 ELT( MONTH( matches.matchdate ) , 'jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec' ) ,' ',
 year( matches.matchdate )) AS datum_NL, 
 TIME_FORMAT( matches.matchtime, '%H:%i' ) AS UUR,
matches.matchtype, matches.division, matches.season, teams.teamname AS thuisploeg, teamhomescore.teamname AS bezoekers, matches.homescore, matches.awayscore, matches.matchday
FROM teams AS teamhomescore
INNER JOIN (
teams
INNER JOIN matches ON teams.teamid = matches.teamhome
) ON teamhomescore.teamid = matches.teamaway
WHERE matchid=$matchid

到目前为止一切顺利。 现在我想更新数据,所以我遇到了问题。更新记录时我是否必须撤消查询?或者我必须这样做? 这是我的基本查询

UPDATE matches SET matchdate='$matchdate', matchtime='$matchtime' , season='$season', division='$division', matchtype='$matchtype' , teamhome='$thuisploeg', teamaway='$teamaway', homescore=IF('$homescore'='',NULL,'$homescore') ,awayscore=IF('$awayscore'='',NULL,'$awayscore'), matchday=$matchday WHERE matchid='$matchid'

0 个答案:

没有答案