Rick
asked on
SQL concat in Where clause
How can I accomplish this?
Select emailAddress
From UserList
Where (fname||" "||lname) = 'John Doe'
Select emailAddress
From UserList
Where (fname||" "||lname) = 'John Doe'
aren't the + enough:
Select emailAddress
From UserList
Where (fname + " " + lname) = 'John Doe'
Select emailAddress
From UserList
Where (fname + " " + lname) = 'John Doe'
ASKER
aelliso3 - I get nothing
emoreau - Invalid column name ' '.
emoreau - Invalid column name ' '.
Try this:
Select emailAddress
From UserList
Where fname = 'John' and lname = 'Doe'
Select emailAddress
From UserList
Where fname = 'John' and lname = 'Doe'
can you provide more information on what you are doing because the error makes no sens to me !
are you running this query from SSMS?
are you running this query from SSMS?
emoreau ... yours had 2 double quotes instead of 2 single quotes ...
doh!
ASKER
I have this table:
tblItems:
ItemID, CreatedBy, CreatedDate
001, John Doe, 9/10/2010 10:15:00 PM
And this table:
tblUsers:
FName, LName, Email
John, Doe, jdoe@email.com
I want to select the email address from tblUsers of whom created ItemID 001. In this case John Doe's email.
ASKER
I'm using vb, I can split 'John Doe' and do what you said above:
Select emailAddress
From UserList
Where fname = 'John' and lname = 'Doe'
But I was hoping to get this accomplished directly from my SQL query.
Select emailAddress
From UserList
Where fname = 'John' and lname = 'Doe'
But I was hoping to get this accomplished directly from my SQL query.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice to help you :-)
It's my 400th accepted answer!
Raj
It's my 400th accepted answer!
Raj
From UserList
Where (fname + ' ' + lname) = 'John Doe'