Computing.Net > Forums > Programming > Access sql query mystery!!

Access sql query mystery!!

Reply to Message Icon

Original Message
Name: intrepid_dave
Date: May 26, 2005 at 02:46:29 Pacific
Subject: Access sql query mystery!!
OS: xp pro
CPU/Ram: barton 3200+, 1 gb ram
Comment:

I have written a query in access that works and looks like this.....

SELECT DISTINCT(Royal.Postcode) AS Postcode, B.[Business Amount], P.[Private Amount]
FROM Royal,
(SELECT Postcode, Count(VMFCode) AS [Business Amount]
FROM Royal
WHERE VMFCode = "RMB"
GROUP BY Postcode, VMFCode) B,
(SELECT Postcode, Count(VMFCode) AS [Private Amount]
FROM Royal
WHERE VMFCode = "RMP"
GROUP BY Postcode, VMFCode) P
WHERE (((B.Postcode)=[Royal].[Postcode]) AND ((P.Postcode)=[Royal].[Postcode]) AND ((Royal.Status)="Active"));

This query works fine, but when i save and close it and then run it, then open it again, it looks like this ...

SELECT DISTINCT (Royal.Postcode) AS Postcode, B.[Business Amount], P.[Private Amount]
FROM Royal, [SELECT Postcode, Count(VMFCode) AS [Business Amount]
FROM Royal
WHERE VMFCode = "RMB"
GROUP BY Postcode, VMFCode]. AS B, [SELECT Postcode, Count(VMFCode) AS [Private Amount]
FROM Royal
WHERE VMFCode = "RMP"
GROUP BY Postcode, VMFCode]. AS P
WHERE (((B.Postcode)=[Royal].[Postcode]) AND ((P.Postcode)=[Royal].[Postcode]) AND ((Royal.Status)="Active"));


The problem now is when i try to amend the query and save it again i get the error :

"Invalid bracketing of name 'SELECT Postcode, Count(VMFCode) AS [Business Amount'.

I get this error also when the data in the database changed. I've tried reverting everything back, but the same happens

Can anyone help????


Report Offensive Message For Removal

Response Number 1
Name: Chi Happens
Date: May 26, 2005 at 06:07:20 Pacific
Subject: Access sql query mystery!!
Reply: (edit)

Access uses a different format than the standard t-sql queries. Your best choice is to save the query to a text file so that you can append to it and then repaste it.

Chi

They mostly come at night...mostly


Report Offensive Follow Up For Removal

Response Number 2
Name: intrepid_dave
Date: May 31, 2005 at 02:13:28 Pacific
Subject: Access sql query mystery!!
Reply: (edit)

Thanks chi, but the error comes when the data is changed also, which is obviously no good. Is there some kind of different bracketing convention or something with Access?




Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Access sql query mystery!!

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software