Wiktor
Wiktor

Reputation: 631

How should I add text to my column's select statement

This is my sql code

SELECT sessionname, left(comment,4)) 
  FROM moma_reporting.comments where name like '%_2016_02_%'
  and comment = '1200'

My output will be :

"WE247JP_2016_02_07__14_48_18";"1200"
"FORD49_2016_02_03__12_42_24";"1200"
"1-GRB-804_2016_02_06__08_20_15";"1200"

What i want to do is to add text to column -comment so it will look like this:

"WE247JP_2016_02_07__14_48_18";"1200-QC"
"FORD49_2016_02_03__12_42_24";"1200-QC"
"1-GRB-804_2016_02_06__08_20_15";"1200-QC"

How i can do this ?

Upvotes: 1

Views: 129

Answers (1)

user330315
user330315

Reputation:

Just concat it:

SELECT sessionname, left(comment,4))||'-QC' 
FROM moma_reporting.comments 
where name like '%_2016_02_%'
  and comment = '1200'

Unrelated, but: left(comment,4)) is useless. The condition and comment = '1200' will never return comments that are longer then 4 characters.

Upvotes: 1

Related Questions