Results 1 to 4 of 4

Thread: Combination of Two fields in one SQL Query

  1. #1
    Join Date
    May 2008
    Posts
    68

    Combination of Two fields in one SQL Query

    hi there

    I have a query regarding SQL database.

    I need to combine two fields in a SQL query and is facing some trouble
    My query is


    SELECT MAN.intcaseID,
    STA.strCaseStatName,
    ACT.strCaseActTypeName,
    MST.strActivityDetail,
    MST.strModifiedBy,
    UPr.strfname,
    UPr.strlname,
    MST.dtiModified
    FROM tbl_casemain MAN LEFT JOIN tbl_caseseverity SEV ON SEV.intCaseSevID = MAN.intCaseSevID
    INNER JOIN tbl_casemaindata MDA ON MDA.intCaseID = MAN.intCaseID
    INNER JOIN tbl_casemainstatus MST ON MST.intCaseID = MAN.intCaseID
    INNER JOIN tbl_casestatus STA ON STA.intCaseStatID = MST.intCaseStatID
    INNER JOIN tbl_caseactivitytype ACT ON ACT.intCaseActTypeID = MST.intCaseActTypeID
    INNER JOIN tbl_casemaindetails MDT ON MDT.intCaseID = MAN.intCaseID
    LEFT JOIN tblUser_profile UPr
    ON UPr.strcuid = MST.strModifiedBy
    WHERE MAN.intcaseID = 19
    ORDER BY MST.dtiModified

    I have also tried using [UPr.strfname] & " " & [UPr.strlname] as FullName, but it is not working for me. Is there a concatenate entry in SQL that I should use? As when I enter #FullName# in my code on the web page it keeps on displaying something different instead of having two columns.

    Please help me in this

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Combination of Two fields in one SQL Query

    SQL uses + and not & to concatenate strings, and single quotes and not double quotes surrounding them.

    [UPr.strfname] + ' ' + [UPr.strlname] AS FullName

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Combination of Two fields in one SQL Query

    try this one:

    SELECT CONCAT(ColumnA, ColumnB) AS ColumnZ
    FROM Table

    ORDER BY 1

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Combination of Two fields in one SQL Query

    i guess this should work:

    select product_id + product_name as product_fullstring
    from tblproduct

Similar Threads

  1. Query in SQL v/s Query in Oracle
    By Satchel in forum Software Development
    Replies: 4
    Last Post: 29-12-2010, 07:19 AM
  2. Want to make query dependent on another query.
    By MACE in forum Software Development
    Replies: 4
    Last Post: 01-02-2010, 05:22 PM
  3. Replies: 3
    Last Post: 16-11-2009, 12:29 PM
  4. MySQL query in a query
    By Rail racer in forum Software Development
    Replies: 3
    Last Post: 21-07-2009, 07:06 PM
  5. Turn on MySQL query cache to speed up query performance
    By DMA2Superman in forum Software Development
    Replies: 3
    Last Post: 07-07-2009, 10:26 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,717,390,619.51451 seconds with 16 queries