有谁能帮我看看这个sql语句代表什么意思?谢谢!

来源:百度知道 编辑:UC知道 时间:2024/05/10 16:46:33
String sql = "select BBSMsg.*,BBSMsg1.item_id item_id1,BBSMsg1.author replyer,"+ "BBSMsg1.compose_date reply_latest_date from BBSMsg "+ "inner join BBSMsg BBSMsg1 on BBSMsg.item_id="+ "BBSMsg1.fathers_id and BBSMsg.latest_replication_id="+ "BBSMsg1.item_id where BBSMsg.is_origional = 1 "+ "order by item_id desc limit "+ (page - 1)* pagesize+ "," + pagesize;
现在数据库中只有BBSMsg这个表,我不清楚为什么会出来一个BBSMsg1?

关键是:inner join BBSMsg BBSMsg1 。
BBSMsg1 是BBSMsg的别名,这个SQL用的是内连接语句inner join
两个表实际上是一个表,用内连接实现SQL查询而已

BBSMsg1是BBSMsg的别名,这里把一张表看作两张表来完成逻辑,事实上就只有一张BBSMsg^_^