Troubleshooting of PostgreSQL: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
mNo edit summary
Tags: Mobile edit Mobile web edit
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
Troubleshooting of PostgreSQL
Troubleshooting of [https://www.postgresql.org/ PostgreSQL]


== Syntax error: 7 ERROR:  LIMIT #,# syntax is not supported ==
== How to fix Syntax error of PostgreSQL ==
=== How to fix Syntax error: 7 ERROR:  LIMIT #,# syntax is not supported ===
Query syntax mer error
Query syntax mer error
<pre>
<pre>
Line 7: Line 8:
FROM my_table
FROM my_table
LIMIT 0,10
LIMIT 0,10
</pre>
Error message
<pre>
Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR:  LIMIT #,# syntax is not supported                                                       
HINT:  Use separate LIMIT and OFFSET clauses.
</pre>
Correct query syntax<ref>[http://www.sqlines.com/postgresql/limit_offset PostgreSQL Queries - OFFSET and LIMIT - Guide, Examples and Alternatives - SQLines Tools]</ref>
<pre>
SELECT *
FROM my_table
LIMIT 10 OFFSET 0
</pre>
=== How to fix ERROR:  operator does not exist: ` character varying ===
The following SQL query has a syntax error:
<pre>
SELECT `my_columm`
from my_table
LIMIT 10
</pre>
Error message
<pre>
ERROR:  operator does not exist: ` character varying
LINE 1: SELECT `content_hash`
              ^
HINT:  No operator matches the given name and argument type. You might need to add an explicit type cast.
</pre>
To fix the error, update the query with the correct syntax:
<pre>
SELECT my_columm
from my_table
LIMIT 10
</pre>
=== How to fix ERROR: argument of WHERE must be type boolean, not type integer ===
Query syntax mer error
<pre>
SELECT *
FROM my_table
WHERE 1
</pre>
</pre>


Line 13: Line 58:
SELECT *  
SELECT *  
FROM my_table
FROM my_table
LIMIT 10 OFFSET 0
WHERE 1 = 1
</pre>
 
or
<pre>
SELECT *
FROM my_table
WHERE TRUE
</pre>
 
=== How to fix the ERROR: column "count" does not exist ===
The following SQL query has a syntax error:
<pre>
SELECT count(*) count, content_hash
from my_table
GROUP BY content_hash
having count >= 2
</pre>
 
To fix the error, update the query with the correct syntax:
<pre>
SELECT count(*) count, content_hash
from my_table
GROUP BY content_hash
having count(*) >= 2
</pre>
</pre>
=== How to fix: The numeric column data all became null after imported ===
[[Troubleshooting of Navicat for PostgreSQL]]
== Further reading ==
* [https://stackoverflow.com/questions/242822/why-would-someone-use-where-1-1-and-conditions-in-a-sql-clause dynamic sql - Why would someone use WHERE 1=1 AND <conditions> in a SQL clause? - Stack Overflow]
* [https://koalatea.io/postgres-insert-ignore/ Working with Insert Into Ignore in Postgres]
== References ==
<references />




{{Template:Troubleshooting}}
{{Template:Troubleshooting}}


[[Category: PostgreSQL]]
[[Category:PostgreSQL]]
[[Category:Database]]
[[Category:Data Science]]
[[Category:Data Science]]

Latest revision as of 16:34, 18 April 2023

Troubleshooting of PostgreSQL

How to fix Syntax error of PostgreSQL[edit]

How to fix Syntax error: 7 ERROR: LIMIT #,# syntax is not supported[edit]

Query syntax mer error

SELECT * 
FROM my_table
LIMIT 0,10

Error message

Uncaught PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR:  LIMIT #,# syntax is not supported                                                         
HINT:  Use separate LIMIT and OFFSET clauses.

Correct query syntax[1]

SELECT * 
FROM my_table
LIMIT 10 OFFSET 0

How to fix ERROR: operator does not exist: ` character varying[edit]

The following SQL query has a syntax error:

SELECT `my_columm`
from my_table
LIMIT 10

Error message

ERROR:  operator does not exist: ` character varying
LINE 1: SELECT `content_hash`
               ^
HINT:  No operator matches the given name and argument type. You might need to add an explicit type cast.

To fix the error, update the query with the correct syntax:

SELECT my_columm
from my_table
LIMIT 10

How to fix ERROR: argument of WHERE must be type boolean, not type integer[edit]

Query syntax mer error

SELECT * 
FROM my_table
WHERE 1

Correct query syntax

SELECT * 
FROM my_table
WHERE 1 = 1

or

SELECT * 
FROM my_table
WHERE TRUE

How to fix the ERROR: column "count" does not exist[edit]

The following SQL query has a syntax error:

SELECT count(*) count, content_hash
from my_table
GROUP BY content_hash
having count >= 2

To fix the error, update the query with the correct syntax:

SELECT count(*) count, content_hash
from my_table
GROUP BY content_hash
having count(*) >= 2

How to fix: The numeric column data all became null after imported[edit]

Troubleshooting of Navicat for PostgreSQL

Further reading[edit]

References[edit]