PHP expert |
|
Klopt, sorry dacht dat "hij gaat bij WITH kapot" genoeg voor jullie geniale mensen was
Citaat: Incorrect syntax near the keyword 'WITH'.
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Incorrect syntax near 'ALLSELECT'.
Dat is als ik het zo probeer:
string selectItem = "SELECT marketGroupID, parentGroupID, marketGroupName FROM "+selectWith;
string selectItem = "SELECT marketGroupID, parentGroupID, marketGroupName FROM "+selectWith;
Deze error krijg ik:
Citaat: Invalid object name 'PagesList'. als ik het zo doe:
string selectItem = "SELECT marketGroupID, parentGroupID, marketGroupName FROM PagesList";
string selectItem = "SELECT marketGroupID, parentGroupID, marketGroupName FROM PagesList";
Als ik een nieuwe query in Microsoft SQL server 2008 aanmaak met deze inhoud doet hij het naar behoren:
WITH PagesList (marketGroupID, parentGroupID, marketGroupName) AS (
SELECT marketGroupID, parentGroupID, marketGroupName
FROM invMarketGroups
WHERE parentGroupID = 209
UNION ALL
SELECT c.marketGroupID, c.parentGroupID, c.marketGroupName
From invMarketGroups as c
INNER JOIN PagesList as p
ON c.parentGroupID = p.marketGroupID
)
SELECT marketGroupID, parentGroupID, marketGroupName FROM PagesList
WITH PagesList (marketGroupID, parentGroupID, marketGroupName) AS ( SELECT marketGroupID, parentGroupID, marketGroupName FROM invMarketGroups WHERE parentGroupID = 209 UNION ALL SELECT c.marketGroupID, c.parentGroupID, c.marketGroupName FROM invMarketGroups AS c INNER JOIN PagesList AS p ON c.parentGroupID = p.marketGroupID ) SELECT marketGroupID, parentGroupID, marketGroupName FROM PagesList
Heb het al opgelost, moest the WITH and SELECT in 1 string var zetten en die gebruiken in query. |