日期:2014-05-18  浏览次数:20772 次

求大神指点!
String sql = "select a.id as id,a.title as title,a.sequence as sequence,b.names as departName,c.names as webName from board as a left join department as b on a.depart_id=b.id join web as c on a.web_id=c.id where 1=1";
这句话什么意思,a.id as id 这是什么意思? join有是什么意思?

------解决方案--------------------
探讨

从:board 表,别名为 a 左连接 department 表,别名 b 它们通过a表的depart_id和b表的id关联。然后得到的结果再和 web 表,别名c表关联。where 1=1恒为true,估计是为了后面拼接字符串所以凑一个where出来。这只是技巧而已。as 是把as前面的字段换成as 后面的字段名,即取别名,join是连接。包括内连接、外联结两种。详细请看联机丛书,join是非……