CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: mySQL query

  1. #1
    Join Date
    Sep 2005
    Posts
    50

    mySQL query

    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

  2. #2
    Join Date
    Jan 2005
    Location
    City of Smiles!
    Posts
    125

    Re: mySQL query

    hi...try this:


    SELECT field1 - field2 as result FROM Table;


    happy coding!

  3. #3
    Join Date
    Apr 2005
    Location
    India
    Posts
    271

    Smile Re: mySQL query

    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

  4. #4
    Join Date
    Sep 2005
    Posts
    50

    Re: mySQL query

    cheers for your replies

    sorted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured