lamiren
lamiren

Reputation: 65

SQL: Append a fix string into selection result set

I'm using Redshift and is trying to add a certain string into string into selection result set.

I took the link below as reference and tried exactly the same thing, but it did not work.

adding string to a select statement to include in result set

Would appreciate if anyone could provide a hint.

SELECT p.Name AS title, 
       p.meta_desc AS description, 
       p.product_Id AS id, 
       'new' AS `condition`
FROM products AS p

Error message:

enter image description here

Upvotes: 0

Views: 479

Answers (3)

Bill Weiner
Bill Weiner

Reputation: 11082

In Redshift column names are quoted by double quotes ("). It may be that condition is a reserved word and needs quotes.

SELECT p.Name AS title, 
       p.meta_desc AS description, 
       p.product_Id AS id, 
       'new' AS "condition"
FROM products AS p

Please post the error message if this doesn't work.

Upvotes: 1

Iman Javadi
Iman Javadi

Reputation: 141

in tsql must use ' character instead of ` character

SELECT p.Name AS title, 
       p.meta_desc AS description, 
       p.product_Id AS id, 
       'new' AS 'condition'
FROM products AS p

or without ' character

SELECT p.Name AS title, 
       p.meta_desc AS description, 
       p.product_Id AS id, 
       'new' AS condition
FROM products AS p

Upvotes: 1

lamiren
lamiren

Reputation: 65

I deleted (`) for the column name then it works....

Upvotes: 1

Related Questions