problem searching data with 2 join table

Questionsproblem searching data with 2 join table
Norman asked 10 years ago

Hi,

Couldn't execute query. The multi-part identifier "MsSecurityWeekEnd.EmployeeID" could not be bound. – SELECT count(*) as c FROM ( SELECT * FROM ( SELECT a.EmployeeID ,(FirstName+' '+LastName) AS EmployeeName ,a.WeekEndDate ,a.RBU ,a.RBT FROM MsSecurityWeekEnd a LEFT JOIN MsEmployee b ON a.EmployeeID=b.EmployeeID ) a WHERE 1=1 AND MsSecurityWeekEnd.EmployeeID LIKE '%2%') pg_tmp

this worked for searching EmployeeName but not for EmployeeID.
any idea how to make it worked?

thx

2 Answers
Norman answered 10 years ago

Hi,

ok i get it to worked with modified SQL.
SELECT
MsSecurityWeekEnd.EmployeeID
,(FirstName+' '+LastName) AS EmployeeName
,MsSecurityWeekEnd.WeekEndDate
,MsSecurityWeekEnd.RBU
,MsSecurityWeekEnd.RBT
FROM MsSecurityWeekEnd
LEFT JOIN MsEmployee ON MsSecurityWeekEnd.EmployeeID=MsEmployee.EmployeeID

Now the problem is : i cannot use the autofilter the EmployeeName.
it returns error :
Couldn't execute query. Invalid column name 'EmployeeName'. – SELECT count(*) as c FROM ( SELECT MsSecurityWeekEnd.EmployeeID ,(FirstName+' '+LastName) AS EmployeeName ,MsSecurityWeekEnd.WeekEndDate ,MsSecurityWeekEnd.RBU ,MsSecurityWeekEnd.RBT FROM MsSecurityWeekEnd LEFT JOIN MsEmployee ON MsSecurityWeekEnd.EmployeeID=MsEmployee.EmployeeID WHERE 1=1 AND EmployeeName LIKE '%l%')

and another questions? can i use alias name in SQL for table actually?

thx

Norman answered 10 years ago

Hi,

i found that using : $col["dbname"] = "(FirstName+' '+LastName)";
solved the problem.

now i understand the use of $col["dbname"] for the complex query.

thx

Your Answer

9 + 19 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?