### SQL: select t.id,t.name,t.sex,t.age t.address,t.phone from user where id = 1
### Cause: org.postgresql.util.PSQLException: ERROR: syntax error at or near "."
Position: 34
; bad SQL grammar [];nested exception is org.postgresql.util.PSQLException: ERROR: syntax error at or near "."
Position: 34
一、学习如何根据错误信息定位sql问题出在哪儿
思路:
1. ERROR: syntax error at or near “.” Position: 34
这句话的意思是,问题出现在第34
个字符附近。
2. 查看sql
select t.id,t.name,t.sex,t.age t.address,t.phone from user where id = 1
第34
个字符是t.address中的特殊符号.
,检查这个.
特殊符号的附件是否有错误写法。
仔细观察,发现t.age后面没写逗号,
导致语法错误
二、错误sql解决
正确的sql:
select t.id,t.name,t.sex,t.age,t.address,t.phone from user where id = 1
错误的sql:
select t.id,t.name,t.sex,t.age t.address,t.phone from user where id = 1
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)