I was reading this question How to determine type of the sql query for jdbcTemplate in JAVA?. The correct answer says, a SELECT query can either start with a SELECT
or a WITH
.
Just for reference, the answer said:
// SELECT subqueries are irrelevant for the final result. So the command, the first verb is indicative of the result (int updateCount vs. ResultSet).
boolean isSqlSelect = sql.toUpperCase().startsWith("SELECT")
|| sql.toUpperCase().startsWith("WITH");
So, now lets say I have a query
SELECT id, name, email FROM users;
Questions
- How can I rewrite that query starting with a
WITH
? - And although the question was for JDBC, is it common for all SQL and ODBC/JDBC?