Click to See Complete Forum and Search --> : mySQL query


jim_scott
October 5th, 2005, 04:51 AM
i have two varchar fields say

field1 varchar(20)
field2 varchar(4)

i want to return a result in the format field1 - field2

my query tries to add the two fields together

select (field1 + ' - ' + field2) as result from table

any help much appreciated

nikko
October 5th, 2005, 12:28 PM
hi...try this:


SELECT field1 - field2 as result FROM Table;


happy coding!

PramodsNair
October 6th, 2005, 06:19 AM
Dear Jim_scott,

You can use the CONCAT function in MySql to get the same.

example:

select CONCAT(field1,"-",field2) FROM tablename;

this will give you the required result

Pramod S Nair

jim_scott
October 7th, 2005, 08:50 AM
cheers for your replies

sorted