JDBC ResultSet get columns with table alias

后端 未结 7 968
春和景丽
春和景丽 2020-11-28 13:22

Imagine I have a query like

SELECT * from table1 a, table2 b where (WHATEVER)

Maybe both tables have the same column name. So I though it

7条回答
  •  忘掉有多难
    2020-11-28 13:46

    ResultSetMetadata.getColumnLabel() is what you need

    (edit) sample example, as stated by bharal in comment

    SELECT * from table1 a, table2 b where (WHATEVER)
    
    ResultSetMetaData rsmd = rset.getMetaData();
    rsmd.getColumnLabel(1);
    

提交回复
热议问题