Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 What is wrong with this syntax?

Author  Topic 

navs
Starting Member

13 Posts

Posted - 2009-05-14 : 07:29:33
This syntax is fine, but the next one isn't. I need help please,


SELECT node.nid AS nid, node_book.title AS node_book_title, node_book.nid AS node_book_nid
FROM node node
LEFT JOIN book book ON node.nid = book.nid
INNER JOIN node node_book ON book.bid = node_book.nid
LEFT JOIN menu_links book_menu_links ON book.mlid = book_menu_links.mlid
WHERE book_menu_links.depth =1



It returns a book's title. Now I want it to return the book's title only when the book belongs to the grade the current user is in.

So I tried the following and I get errors:
-------------------------------------------
SELECT node.nid AS nid,
node_book.title AS node_book_title,
node_book.nid AS node_book_nid
FROM node node
LEFT JOIN book book ON node.nid = book.nid
INNER JOIN node node_book ON book.bid = node_book.nid
INNER JOIN book content_type_book ON book.bid = content_type_book.uid
LEFT JOIN menu_links book_menu_links ON book.mlid = book_menu_links.mlid
WHERE book_menu_links.depth = 1
AND user.uid = $user.uid
------------------------------------------------

WHAT SHOULD I DO TO MAKE THIS WORK?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-05-14 : 07:31:45
What is $user for type of table?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -