BountyHunter
BountyHunter

Reputation: 1411

combining two varchar fields in same SELECT statement without merging values

The SQL query in my PHP file is

SELECT start_time,end_time FROM data;

This returns the two varchar fields in two different columns. Now i wish to combine these. So I tried

Select start_time+' '+end_time as time from data;

This returns some numeric value. So I tried:

Select cast(start_time+' '+end_time) as time from data;

If the data in my table is start_time = 8:00 a.m end_time = 9:30 a.m

how can I display 8:00 a.m - 9:30 a.m.

Upvotes: 4

Views: 11328

Answers (3)

Isselmou SNEIGUEL
Isselmou SNEIGUEL

Reputation: 21

SELECT CONCAT(start_time,' ',end_time) as time FROM TEBLENAME

Upvotes: 2

Roman Marusyk
Roman Marusyk

Reputation: 24609

Select CONCAT(start_time, ' - ', end_time) as time FROM data

Upvotes: 7

gen_Eric
gen_Eric

Reputation: 227290

You're looking for CONCAT().

SELECT CONCAT(start_time, ' ', end_time) AS time FROM data;

Upvotes: 3

Related Questions