Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ERROR "An expression of non-boolean type specified in a context"

Status
Not open for further replies.

ReK410

IS-IT--Management
Sep 18, 2003
60
US
I'm trying to run a query against our database, it was an older query that I've had to hack up with new table/column names.

Here's the query
SELECT p21_view_inv_mast.item_id, p21_view_inv_mast.item_desc, p21_view_inv_loc.gl_account_no
FROM dbo.p21_view_inv_loc p21_view_inv_loc, dbo.p21_view_inv_mast p21_view_inv_mast
WHERE p21_view_inv_loc.inv_mast_uid p21_view_inv_mast.inv_mast_uid

The error I'm getting is:
Msg 4145, Level 15, State 1, Line 3
An expression of non-boolean type specified in a context where a condition is expected, near 'p21_view_inv_mast'.

any help would be appreciated!
 
You're missing an operator (probably equal)

Code:
SELECT p21_view_inv_mast.item_id, p21_view_inv_mast.item_desc, p21_view_inv_loc.gl_account_no
FROM dbo.p21_view_inv_loc p21_view_inv_loc, dbo.p21_view_inv_mast p21_view_inv_mast
WHERE p21_view_inv_loc.inv_mast_uid [!]=[/!] p21_view_inv_mast.inv_mast_uid

Also... I suggest you use the inner join syntax. It would be like this...

Code:
[COLOR=blue]SELECT[/color] p21_view_inv_mast.item_id, 
       p21_view_inv_mast.item_desc, 
       p21_view_inv_loc.gl_account_no
[COLOR=blue]FROM[/color]  dbo.p21_view_inv_loc p21_view_inv_loc
      [COLOR=blue]Inner[/color] [COLOR=blue]Join[/color] dbo.p21_view_inv_mast p21_view_inv_mast
        [COLOR=blue]on[/color] p21_view_inv_loc.inv_mast_uid = p21_view_inv_mast.inv_mast_uid

-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
which is clearer
this
Code:
SELECT p21_view_inv_mast.item_id, p21_view_inv_mast.item_desc, p21_view_inv_loc.gl_account_no
FROM dbo.p21_view_inv_loc p21_view_inv_loc, dbo.p21_view_inv_mast p21_view_inv_mast
WHERE p21_view_inv_loc.inv_mast_uid p21_view_inv_mast.inv_mast_uid

or this?
Code:
SELECT mast.item_id, 
mast.item_desc, 
loc.gl_account_no
FROM dbo.p21_view_inv_loc loc
INNER JOIN dbo.p21_view_inv_mast mast
ON  loc.inv_mast_uid  = mast.inv_mast_uid

there is no point aliasing the table name with the same name

FROM dbo.p21_view_inv_loc p21_view_inv_loc

it is already that name

Denis The SQL Menace
--------------------
SQL Server Code,Tips and Tricks, Performance Tuning
SQLBlog.com, Google Interview Questions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top