我在Java中的代碼,我需要插入結果放入新表創建新表。這可能只是編輯這個查詢?SQLite中與查詢結果
ResultSet result = stat.executeQuery("SELECT artist, COUNT(artist) AS countartist FROM table1 GROUP BY artist ORDER BY countartist DESC;");
我在Java中的代碼,我需要插入結果放入新表創建新表。這可能只是編輯這個查詢?SQLite中與查詢結果
ResultSet result = stat.executeQuery("SELECT artist, COUNT(artist) AS countartist FROM table1 GROUP BY artist ORDER BY countartist DESC;");
試試這個:
的ResultSet結果= stat.executeUpdate( 「CREATE TABLE newtable的AS SELECT藝術家,COUNT(藝術家)AS countartist FROM表1 GROUP BY藝術家ORDER BY countartist DESC」);
「java.sql.SQLException:[SQLITE_ERROR] SQL錯誤或缺少數據庫(近」(「:語法錯誤)」 – bardamu
對不起,我把一個現在嘗試一下 – swmcdonnell
「java.sql.SQLException:查詢不返回ResultSet」它可能是我的代碼的東西嗎?以前的查詢工作正常 – bardamu
'insert into some_table(col1,col2)select artist ...' –
我需要在創建新表之前嗎? – bardamu
你可以這樣做,或使用'創建表tab_name作爲選擇藝術家...' –