问题描述
假设我已经创建了 table3,并尝试使用以下代码向其中插入数据
WITH table1
AS
(SELECT 1 AS key,'One' AS value),table2
AS
(SELECT 1 AS key,'I' AS value)
INSERT TABLE table3
SELECT t1.key,t1.value,t2.value
FROM table1 t1
JOIN table2 t2
ON (t1.key = t2.key)
但是,我收到一个错误,因为无法识别 select 子句中的输入“插入”。如果我只是删除插入语句,那么查询运行得很好。
这是语法问题吗?或者我不能使用 with 子句插入?
解决方法
根据需要使用 INTO 或 OVERWRITE:
INSERT OVERWRITE TABLE table3 --will overwrite any existing data
或
public static int findReverse(int num,int temp){
if(num==0){
return temp;
}else if(num<10){
return temp*10 + num; //up to this is stopping condition
}else{
temp = temp*10 + num%10;
return findReverse(num/10,temp);
}
}
public static void main(String args[]){
int num = 120021;
int reverseNum = findReverse(num,0);
System.out.println(reverseNum);
if(num == reverseNum)
System.out.println(num +" is a palindrome!");
else
System.out.println(num +" is not a palindrome!");
}