HELP! Convert SQL query to Access?
From: Byron (Byron_at_discussions.microsoft.com)
Date: 10/09/04
- Next message: fredg: "Re: Conditional statement within a query?"
- Previous message: Allen Browne: "Re: Access 97 - Multiple Table Query Question"
- Next in thread: John Spencer (MVP): "Re: HELP! Convert SQL query to Access?"
- Reply: John Spencer (MVP): "Re: HELP! Convert SQL query to Access?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 9 Oct 2004 09:07:02 -0700
For some reason the query below returns an error in Access complaing of a
missing operator, but it executes fine in SQL 2000. I don't normally use
Access, so I'm at a loss here. Can anybody tell me what might be wrong with
it in Access's eyes? It just inserts a child node into a tree where the ID
of the parent node = 1.
Schema in brief:
U_ID - primary key (int)
U_Left - Left limit of node (int)
U_Right - Right limit of node (int)
U_name - Name of node (string)
For example, the parent node starts with a U_ID of 1 and U_Left and U_Right
of 1 and 2 respectively. I insert a child node with U_Left and U_Right of 0,
the run this query to adjust the child node to 2 and 3, and the parent node
to 1 (no change) and 4, so that the child nodes U_Left and U_Right fall
between those of the parent. Any other nodes are adjusted by the same call.
UPDATE Unit
SET U_Left = CASE
WHEN U_Left > (SELECT U1.U_Left FROM Unit AS U1 WHERE U1.U_ID = 1) THEN
U_Left + 2
WHEN U_Left = 0 THEN (SELECT U1.U_Left + 1 FROM ExerciseUnit AS U1 WHERE
U1.U_ID = 1)
ELSE U_Left END,
U_Right = CASE WHEN U_Right > (SELECT U1.U_Left FROM Unit AS U1 WHERE
U1.U_ID = 1D) THEN U_Right + 2
WHEN U_Left = 0 THEN (SELECT U2.U_Left + 2 FROM Unit AS U2 WHERE U2.U_ID = 1)
ELSE U_Right
END
- Next message: fredg: "Re: Conditional statement within a query?"
- Previous message: Allen Browne: "Re: Access 97 - Multiple Table Query Question"
- Next in thread: John Spencer (MVP): "Re: HELP! Convert SQL query to Access?"
- Reply: John Spencer (MVP): "Re: HELP! Convert SQL query to Access?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|