Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
SQL
SELECT Student.StudentID,(Student.FirstName+' '+Student.LastName)
AS StudentName,Employee.EmployeeID,(Employee.FirstName+' '+Employee.LastName)
FROM Student INNER JOIN Employee ON Student.BranchID=Employee.BranchID
WHERE Student.BranchID OR Employee.BranchID="+ ViewState["BranchID"] + ";


I am having trouble with this Join .It is Showing the following error..

An expression of non-boolean type specified in a context where a condition is expected, near 'OR'.
Posted
Updated 13-Mar-14 4:41am
v2

use any one either Student.BranchID/Employee.BranchID, but not both
 
Share this answer
 
Comments
uditCsharp 13-Mar-14 8:27am    
I have two tables Student and Employee... It is possible that student table does not have data
but Employee table might have .Same is happening here Employee Table contains the data related to BranchID but Student table doesn't therefore it it not returning any row.
vsrikanth87 13-Mar-14 8:48am    
then whats the need of join over there when there is no data in anyone of tables having unique coloums
in your where condition you have not specified valut to compare with Student.BranchID

WHERE Student.BranchID OR Employee.BranchID="+ ViewState["BranchID"] + ";

It should be like

WHERE Student.BranchID='someValue' OR Employee.BranchID="+ ViewState["BranchID"] + ";
 
Share this answer
 
Comments
uditCsharp 13-Mar-14 8:27am    
I have two tables Student and Employee... It is possible that student table does not have data
but Employee table might have .Same is happening here Employee Table contains the data related to BranchID but Student table doesn't therefore it it not returning any row.
It's a silly mistake. Error itself says something :
Quote:
An expression of non-boolean type specified in a context where a condition is expected, near 'OR'.

So try with this,
SELECT Student.StudentID,(Student.FirstName+' '+Student.LastName)
AS StudentName,Employee.EmployeeID,(Employee.FirstName+' '+Employee.LastName)
FROM Student INNER JOIN Employee ON Student.BranchID=Employee.BranchID
WHERE Student.BranchID="+ ViewState["BranchID"]"+ OR Employee.BranchID="+ ViewState["BranchID"]";


-KR
 
Share this answer
 
try this:

SQL
SELECT Student.StudentID,(Student.FirstName+' '+Student.LastName)
AS StudentName,Employee.EmployeeID,(Employee.FirstName+' '+Employee.LastName)
FROM Student INNER JOIN Employee ON Student.BranchID=Employee.BranchID
WHERE Student.BranchID OR Employee.BranchID="+ ViewState["BranchID"] + ";


SQL
SELECT Student.StudentID,(Student.FirstName+' '+Student.LastName)
AS StudentName,Employee.EmployeeID,(Employee.FirstName+' '+Employee.LastName)
FROM Student INNER JOIN Employee ON Student.BranchID=Employee.BranchID
WHERE Student.BranchID="+ ViewState["BranchID"] + " OR Employee.BranchID="+ ViewState["BranchID"] + ";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900