2013-07-29 68 views
1

我試過以下查詢在密碼。Neo4j - 發生無效的查詢錯誤

START other=node(*) 
WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1 
WITH other, me=node:node_auto_index(UserID = '1') 
MATCH me-[myR:friends]-(x) 
RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath 
     // myR.ApprovalStatus, COUNT(distinct pMutualFriends) AS mutualFriends 
//ORDER BY mutualFriends DESC 
LIMIT 100; 

但它給了我錯誤。

These columns can't be listen in the WITH statement without renaming: me=node 

那麼,這個查詢有什麼問題?

回答

2

你需要做的另一個START子句來做到這一點:

START other=node(*) 
WHERE other.FirstName =~ "(?i)dh.*" AND other.UserID <> 1 
WITH other 
START me=node:node_auto_index(UserID = '1') 
MATCH me-[myR:friends]-(x) 
RETURN other.UserID, other.UserName, other.FirstName, other.LastName, other.ImagePath 
    // myR.ApprovalStatus, COUNT(distinct pMutualFriends) AS mutualFriends 
//ORDER BY mutualFriends DESC 
LIMIT 100; 

這應該是語法正確。我不完全確定你的查詢想要做什麼 - 它感覺不對,因爲這兩個查詢沒有連接在一起,因此你將得到othermeme/x的笛卡爾積在結果中。

+0

謝謝@ wes-freeman,請看看我的另一個問題。鏈接:http://stackoverflow.com/questions/17917884/join-result-set/17933098?noredirect=1#17933098 –