我搜索了很长时间的答案并做了以下事情:
(1)
query = "SELECT COUNT(*) FROM %s WHERE user_name = %s" % (table_name, username)
result = conn.query(query).result()[0][0]
if result == 0:
(do something)
(2)
query = "SELECT 1 FROM %s WHERE user_name = %s" %(table_name, username)
result = conn.query(query).result()[0][0]
if result == ' ':
(do something)
(3)
query = "SELECT EXISTS (SELECT 1 FROM %s WHERE user_name = %s)" %(table_name, username)
result = conn.query(query).result()[0][0]
if result == 't':
(do something)
但一切都不起作用......错误总是:
column "Tom" does not exist
因为它真的不存在,我只想检查它是否存在。任何帮助表示赞赏。