0

I am trying to create an insert query which contains the the semicolon and single quote together and i escaped the single quote already but the query still does not works until i remove the semi colon. Please help

Not Working

INSERT INTO users (email, website) VALUES ('demo@demo.com',
 '=The_Dos_And_Don\'ts Business3735841;n=6')

Working (Semicolon Removed)

INSERT INTO users (email, website) VALUES ('demo@demo.com', 
'=The_Dos_And_Don\'ts Business3735841n=6')
S-Man
  • 22,521
  • 7
  • 40
  • 63
Khanakia
  • 723
  • 1
  • 8
  • 20
  • 3
    The `\'` should not work. It should be `''` The semicolon works without any problems: https://dbfiddle.uk/?rdbms=postgres_9.4&fiddle=29f320f42a354af583837e5faec9ebdd – S-Man May 14 '19 at 15:02

2 Answers2

1

Postgres 8.4:
Both ways work, escaping with \' and '', see the demo.
Postgres 9.4+:
Only '' works, see the demo.
The semicolon does not affect the result.

forpas
  • 160,666
  • 10
  • 38
  • 76
0

The semicolon should not make any problems: demo: db<>fiddle

The escape of the single quote should be done with '': demo: db<>fiddle

Both in combination is no problem as well: demo: db<>fiddle

Your code works fine if the escape of the single quote would be done correctly: demo: db<>fiddle

S-Man
  • 22,521
  • 7
  • 40
  • 63
  • @AmanBansal Did this help? If so, please do not forget to accept (showing that the problem is solved) and upvote (honors the work of the repliers) the relevant answers :) – S-Man May 14 '19 at 16:40