troubleshooting Question

SQL subquery in Main query

Avatar of urjudo
urjudoFlag for United States of America asked on
Microsoft SQL ServerSQL
13 Comments1 Solution21 ViewsLast Modified:
Hi experts,
I have a SQL query question.
I need to create a query for Search purpose.  I have a table named Empl, it's an Employee table, it has Empl_LN, Empl_FN, Empl_Add, I want like to have an alias name for Emloyee name, and I would like to use the Employee name for LIKE operator to search.  I know I have to create a subquey for the Employee name because if I just create in the main query, the Employee name is an alias name but it doesn't have the table name in the query.  

Here is my query:
SELECT EmplNo, Empl_LN, Empl_FN,
FROM EMPL
    (SELECT Empl_LN + ', ' + Empl_FN AS EmployeeName
        FROM EMPL)
WHERE EmployeeName LIKE ?
Order By Empl_LN

It gave me an error message.  I couldn't figure it out.  any help will be very appreciated!

Thanks
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros