需要在MySQL中使用别名内连接列

ast*_*ght 4 mysql inner-join

SELECT AlertTypeID FROM incidentalert 
INNER JOIN incidentalerttype 
ON incidentalert.alerttypeid=incidentalerttype.AlertTypeID
WHERE IncidentID=111210
Run Code Online (Sandbox Code Playgroud)

AlertTypeID是表1中的列,表2中是主键.我如何消除歧义?

eve*_*ton 5

试试这个:

SELECT 
    ia.AlertTypeID 
FROM
    incidentalert ia 
    inner join incidentalerttype iat on iat.alerttypeid=ia.AlertTypeID
where 
    ia.IncidentID=111210
Run Code Online (Sandbox Code Playgroud)