-4

I am trying to replace all the 'abc' in column1 with blanks but received this error. Help will be appreciated!

SELECT * 
REPLACE(column1, 'abc', '') 
FROM database.table;
PrimeOfKnights
  • 426
  • 5
  • 17
Alex Gu
  • 1
  • 1
  • 2
    If you insist on not using backticks, don't name your table `table`. – Siguza Aug 17 '17 at 20:11
  • What was the error? I can see at least three problems with the query. No comma after *, no backticks on database, no backticks on table. – Sloan Thrasher Aug 17 '17 at 20:18
  • Thank you!! It was the 'no comma after *'. I didn't realize you needed to put commas after the select statement in general. – Alex Gu Aug 17 '17 at 20:48

2 Answers2

1

Assuming reserved words are only illustrative then following should work ref:

SELECT *, REPLACE(column1,'abc','') FROM database.table;

As @Sloan Thrasher observed you have missed a comma to separate the columns. If the reserved words really are used you need to put them in backticks or you will get a syntax error see SO discussion. So the query would become:

SELECT *, REPLACE(column1,'abc','') FROM `database`.`table`;
Lew Perren
  • 1,209
  • 1
  • 10
  • 14
0

Try the below:

UPDATE database.table SET column1 = REPLACE(column1, 'abc', '');

  • this assumes he wants to update the data in column1 where the question suggests he justs wants to change the output from the select query. Using this syntax could damage his data if it was not what he intended. – Lew Perren Aug 17 '17 at 20:50