tags:

views:

34

answers:

4
+1  Q: 

Error in the query

$sql="SELECT users.*,designation.designation FROM `users` LEFT JOIN designation ON users.desgid=designation.id WHERE deptid='$deptid'"

I get deptid is ambigous when i execute the query.

+2  A: 

There is a column named deptid in both your users table and your designation table. Qualify the column name in your WHERE clause by saying "table_name.deptid"

AJ
+2  A: 

It sounds like deptid is in both the users and designation table. If so, you need to put

... WHERE users.deptid='$deptid'

or

... WHERE designation.deptid='$deptid'

as appropriate.

Paul Stephenson
+1  A: 

Since you are joining two tables with deptid, it is unknown which table it should come from. You'll have to qualify like you do with designation in the SELECT.

WHERE designation.deptid='$deptid'
rosscj2533
+1  A: 

Try this:

$sql="SELECT users.*,designation.designation FROM `users` LEFT JOIN designation ON users.desgid=designation.id WHERE deptid=$deptid"
Sarfraz