简体   繁体   中英

Need explanation with MySQL query

We have a MySQL database, which contains the table SportsTicker with following columns (as MySQL workbench shows):

'IDSportsTicker', 'int(11)', 'NO', 'PRI', NULL, ''
'SportsID', 'smallint(6)', 'NO', '', '1', ''
'HomeTeamID', 'int(11)', 'NO', '', NULL, ''
'ForeignTeamID', 'int(11)', 'NO', '', NULL, ''
'LeagueID', 'int(11)', 'NO', '', NULL, ''
'CoverageID', 'smallint(2)', 'NO', '', NULL, ''
'PlayStateID', 'smallint(2)', 'NO', '', NULL, ''
'StadiumID', 'int(11)', 'NO', '', NULL, ''
'dateTime', 'datetime', 'NO', '', NULL, ''
'neutralGround', 'bit(1)', 'NO', '', 'b\'0\'', ''
'scoutConfirmed', 'bit(1)', 'NO', '', NULL, ''
'booked', 'bit(1)', 'NO', '', 'b\'0\'', ''
'oddsAvailable', 'bit(1)', 'YES', '', 'b\'0\'', ''
'liveOddsAvailable', 'bit(1)', 'NO', '', 'b\'0\'', ''

And I have a query, which works:

SELECT ST.IDSportsTicker, ST.HomeTeamID, T.name as HomeTeamName, ST.ForeignTeamID, 
 AW.name as AwayTeamName, ST.LeagueID, L.name, ST.dateTime
FROM SportsTicker ST 
 JOIN Team T ON ST.HomeTeamID = T.IDTeam
 JOIN Team AW ON ST.ForeignTeamID = AW.IDTeam
 JOIN League L ON ST.LeagueID = L.IDLeague;

I am just curious, what all those 'ST.', 'T.', 'AW.' and other prefixes mean?

Thank you very much.

They're aliases , a way of giving the table an alternate name in your query. You can see how they're defined in the FROM parameters of your query (eg FROM SportsTicker ST, where ST is the alias that the table is referred to elsewhere in your query).

这些是别名,例如好听的名称或临时名称,用于以排序形式调用表。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM