Avatar billede OWB Novice
02. marts 2006 - 00:54 Der er 11 kommentarer og
1 løsning

Hjælp til Access query builder

Hej.

Jeg har en Access DB som der laves nogle SQL kald til fra noget ASP kode. Jeg har brug for at uddvide disse SQL kald til at indeholde et felt mere, fra en ekstra tabel. SQL kaldene ser ud som følger:

1:
sql= "SELECT Products.*, ProductToCategory.CatID As MainCatID FROM Products, ProductToCategory WHERE Products.ProdID IN ( '" & Replace(Application("Featured"),",","','") & "' ) AND Products.ProdID = ProductToCategory.ProdID AND ProductToCategory.IsMain = 1" & sqlOrderBy

2:
sql= "SELECT Products.*, ProductToCategory.CatID As MainCatID FROM Products INNER JOIN (Categories INNER JOIN ProductToCategory ON Categories.CatID = ProductToCategory.CatID) ON Products.ProdID = ProductToCategory.ProdID WHERE Products.Offer > 0 AND ProductToCategory.IsMain = 1 AND (Products.Show = 1 AND Categories.Show = 1 ) " & sqlOrderBy

3:
sql= "SELECT Products.*, ProductToCategory.CatID As MainCatID FROM Products INNER JOIN (Categories INNER JOIN ProductToCategory ON Categories.CatID = ProductToCategory.CatID) ON Products.ProdID = ProductToCategory.ProdID WHERE Products.ManuID= '" & ManuID & "' AND ProductToCategory.IsMain = 1 AND (Products.Show = 1 AND Categories.Show = 1 ) " & sqlOrderBy

4:
sql= "SELECT Products.*, ProductToCategory.CatID As MainCatID FROM Products, ProductToCategory, Categories, commonlist WHERE Products.ProdId = Commonlist.ProdId AND Products.ProdID = ProductToCategory.ProdID AND ProductToCategory.CatID = Categories.CatID AND ProductToCategory.IsMain = 1 AND UserID = '" & Session("UserID") & "' AND (Products.Show = 1 AND Categories.Show = 1) ORDER BY Products.Name"

5:
sql= "SELECT products.*, ProductToCategory.CatID As MainCatID FROM Products INNER JOIN (Categories INNER JOIN ProductToCategory ON Categories.CatID = ProductToCategory.CatID) ON Products.ProdID = ProductToCategory.ProdID WHERE (" & strCrit & ") " & strSQL & strSQLPrice & " AND (Products.Show = 1 AND Categories.Show = 1) AND ProductToCategory.IsMain = 1 ORDER BY Products.Name"

Fælles for alle 5 kald, ønsker jeg feltet "Manufacturer" fra tabellen "Manufacturer" medtaget.

Et skærmdump af de samlede relationer mellem tabellerne er at finde her: http://85.81.103.17/060226.htm

Hvis der er nogle der har mod på at hjælpe, kan DB'en sendes via e-mail.

På forhånd tak.
Avatar billede Slettet bruger
02. marts 2006 - 01:19 #1
Du er velkommen til at sende den til spgeertz på hotmail!~)

Husk at zippe...
Avatar billede OWB Novice
02. marts 2006 - 08:45 #2
Det er hermed sket. :-)
Avatar billede terry Ekspert
02. marts 2006 - 20:04 #3
Have you received an answer to your questions? If not then if you can send me your dB I'll take a look when I have a bit of time. I think you have my email
Avatar billede OWB Novice
02. marts 2006 - 20:20 #4
I have not received an answer, so I guess it will be OK to send it to you Terry.
Avatar billede terry Ekspert
03. marts 2006 - 08:16 #5
I've received your mail, will take a look during the day.
spg. can you drop a comment if you have made any alterations, so that I dont do anything already done.
Avatar billede OWB Novice
03. marts 2006 - 08:59 #6
Hi Terry. I have not made any changes to the DB, and guess I will wait until I receive something :-)
Avatar billede terry Ekspert
03. marts 2006 - 09:06 #7
dB sent return. I've made 5 queries which need calling as shown here. NOT Tested!!!


1:
sql = "SELECT * from qry1 WHERE Products.ProdID IN ( '" & Replace(Application("Featured"),",","','") & "' ) AND

Products.ProdID = ProductToCategory.ProdID " & sqlOrderBy


2:
sql = "SELECT * from qry2 " & sqlOrderBy

Original SQL doesnt produce any output!


3:
sql = "SELECT * from qry3 WHERE Products.ManuID= '" & ManuID & "' " & sqlOrderBy

4:
sql = "SELECT * from qry4 WHERE UserID = '" & Session("UserID") & "' "  & sqlOrderBy


5:
sql = "SELECT * from qry5 WHERE (" &  strCrit & ") " & strSQL & strSQLPrice
Avatar billede OWB Novice
03. marts 2006 - 13:04 #8
I don't think I have received the DB yet?
Avatar billede terry Ekspert
03. marts 2006 - 14:26 #9
strange!

I'll send it again
Avatar billede OWB Novice
03. marts 2006 - 14:31 #10
It's now received, thank you, I will take a look. :-)
Avatar billede OWB Novice
05. marts 2006 - 20:01 #11
Terry made me the following modifications, which solve my problems.

1:
sql = "SELECT * from qry1 WHERE Products.ProdID IN ( '" & Replace(Application("Featured"),",","','") & "' )  " & sqlOrderBy

4:
sql = "SELECT * from qry4 WHERE UserID = '" & Session("UserID") & "' "

I guess this information is not much useful for anybody without the DB. I will e-mail it on request.

Tanks Terry.
Avatar billede terry Ekspert
06. marts 2006 - 12:28 #12
thanks
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester