Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 19-02-2009
Member
 
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
Reply With Quote
  #2  
Old 19-02-2009
Member
 
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
Reply With Quote
  #3  
Old 19-02-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Combination of Two fields in one SQL Query

try this one:

SELECT CONCAT(ColumnA, ColumnB) AS ColumnZ
FROM Table

ORDER BY 1
Reply With Quote
  #4  
Old 19-02-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Combination of Two fields in one SQL Query

i guess this should work:

select product_id + product_name as product_fullstring
from tblproduct
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Combination of Two fields in one SQL Query"
Thread Thread Starter Forum Replies Last Post
Query in SQL v/s Query in Oracle Satchel Software Development 4 29-12-2010 07:19 AM
Want to make query dependent on another query. MACE Software Development 4 01-02-2010 05:22 PM
SQL query to return unique output based two fields from one table Jabeen Software Development 3 16-11-2009 12:29 PM
MySQL query in a query Rail racer Software Development 3 21-07-2009 07:06 PM
Turn on MySQL query cache to speed up query performance DMA2Superman Software Development 3 07-07-2009 10:26 AM


All times are GMT +5.5. The time now is 01:14 PM.