Connecting Tech Pros Worldwide Forums | Help | Site Map

Help on Sql in Access and ASP

Member
 
Join Date: Jul 2008
Posts: 123
#1: Oct 8 '09
im have tables in access,Customer,Products and Order Table...

Customer Table:
Expand|Select|Wrap|Line Numbers
  1. Cust_ICNumber (PK) 
  2. Cust_Name 
  3. Cust_Address 
  4. Cust_PrimaryNumber 
  5. Cust_SecondaryNumber 
  6. Cust_Company 
  7. Cust_CompanyType 
  8.  
Products Table
Expand|Select|Wrap|Line Numbers
  1. Product_ID (PK) 
  2. Product_Name 
  3. Product_Price 
  4. Product_Picture 
  5.  
Order Table
Expand|Select|Wrap|Line Numbers
  1. Order_ID(PK) 
  2. Product_ID(FK) 
  3. Order_Quantity 
  4. Order_Date 
  5. Customer_ICNumber (FK) 
  6. Total_Price 
  7.  
I intend to output bill (a classic asp file) from order table which will display Order ID,Product Name,Product Price, Customer Name,Customer Address,Order Date.
I wondering if this sql is correct and can be used in classic ASP
Expand|Select|Wrap|Line Numbers
  1. SELECT tCustomer.Cust_Name,
  2.        tCustomer.Cust_Address,
  3.        tProducts.Product_Name,
  4.        tOrder.Order_Quantity,
  5.        tOrder.Order_Date,
  6.        tOrder.Order_ID,
  7.        tOrder_Total_Price
  8.  
  9. FROM   (((Order AS tOrder LEFT JOIN
  10.        Customer AS tCustomer
  11.   ON   tOrder.Customer_ICNumber=tCustomer.Cust_ICNumber) LEFT JOIN
  12.        Products AS tProducts
  13.   ON   tOrder.Product_ID=tProducts.Product_ID);
because I have been trying to use this code but i keep getting error on this at the FROM clause.
best answer - posted by MikeTheBike
Quote:

Originally Posted by puT3 View Post

im have tables in access,Customer,Products and Order Table...

Customer Table:

Expand|Select|Wrap|Line Numbers
  1. Cust_ICNumber (PK) 
  2. Cust_Name 
  3. Cust_Address 
  4. Cust_PrimaryNumber 
  5. Cust_SecondaryNumber 
  6. Cust_Company 
  7. Cust_CompanyType 
  8.  
Products Table
Expand|Select|Wrap|Line Numbers
  1. Product_ID (PK) 
  2. Product_Name 
  3. Product_Price 
  4. Product_Picture 
  5.  
Order Table
Expand|Select|Wrap|Line Numbers
  1. Order_ID(PK) 
  2. Product_ID(FK) 
  3. Order_Quantity 
  4. Order_Date 
  5. Customer_ICNumber (FK) 
  6. Total_Price 
  7.  
I intend to output bill (a classic asp file) from order table which will display Order ID,Product Name,Product Price, Customer Name,Customer Address,Order Date.
I wondering if this sql is correct and can be used in classic ASP
[CODE}
SELECT tCustomer.Cust_Name, tCustomer.Cust_Address, tProducts.Product_Name,tOrder.Order_Quantity, tOrder.Order_Date,tOrder.Order_ID, tOrder_Total_Price FROM (((Order AS tOrder LEFT JOIN Customer AS tCustomer ON tOrder.Customer_ICNumber = tCustomer.Cust_ICNumber) LEFT JOIN Products AS tProducts ON tOrder.Product_ID = tProducts.Product_ID); [/code]

because I have been trying to use this code but i keep getting error on this at the FROM clause.

Hi
I am not too sure about classic ASP, I have not used it at all (in anger) but have two comments on you query

1. Your have, too many opening brackets in the FROM clause (hence the error?)

2. I not sure why you have used alias named for each tables (perhaps this is for ASP!)?

Does that help?


MTB

Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#2: Oct 8 '09

re: Help on Sql in Access and ASP


Quote:

Originally Posted by puT3 View Post

im have tables in access,Customer,Products and Order Table...

Customer Table:

Expand|Select|Wrap|Line Numbers
  1. Cust_ICNumber (PK) 
  2. Cust_Name 
  3. Cust_Address 
  4. Cust_PrimaryNumber 
  5. Cust_SecondaryNumber 
  6. Cust_Company 
  7. Cust_CompanyType 
  8.  
Products Table
Expand|Select|Wrap|Line Numbers
  1. Product_ID (PK) 
  2. Product_Name 
  3. Product_Price 
  4. Product_Picture 
  5.  
Order Table
Expand|Select|Wrap|Line Numbers
  1. Order_ID(PK) 
  2. Product_ID(FK) 
  3. Order_Quantity 
  4. Order_Date 
  5. Customer_ICNumber (FK) 
  6. Total_Price 
  7.  
I intend to output bill (a classic asp file) from order table which will display Order ID,Product Name,Product Price, Customer Name,Customer Address,Order Date.
I wondering if this sql is correct and can be used in classic ASP
[CODE}
SELECT tCustomer.Cust_Name, tCustomer.Cust_Address, tProducts.Product_Name,tOrder.Order_Quantity, tOrder.Order_Date,tOrder.Order_ID, tOrder_Total_Price FROM (((Order AS tOrder LEFT JOIN Customer AS tCustomer ON tOrder.Customer_ICNumber = tCustomer.Cust_ICNumber) LEFT JOIN Products AS tProducts ON tOrder.Product_ID = tProducts.Product_ID); [/code]

because I have been trying to use this code but i keep getting error on this at the FROM clause.

Hi
I am not too sure about classic ASP, I have not used it at all (in anger) but have two comments on you query

1. Your have, too many opening brackets in the FROM clause (hence the error?)

2. I not sure why you have used alias named for each tables (perhaps this is for ASP!)?

Does that help?


MTB
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,765
#3: Oct 8 '09

re: Help on Sql in Access and ASP


PuT3, you've clearly gone to some trouble laying the tables out, which is appreciated. I expect if you'd done the same with the SQL you would have seen the problem yourself very easily (No criticism - just irony - you did a good job overall).

MTB hit the nail on the head (and he even managed it before the reformat - Kudos).

PS. @MTB - Using Aliases is not too unusual. Sometimes simply to see them displayed in a standard format. I use them myself sometimes to shorten the names so making qualifying field references easier.
Member
 
Join Date: Jul 2008
Posts: 123
#4: Oct 9 '09

re: Help on Sql in Access and ASP


oo..That's mean i should delete the brackets ok...i will try it...thanks...
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#5: Oct 9 '09

re: Help on Sql in Access and ASP


Quote:

Originally Posted by NeoPa View Post

PS. @MTB - Using Aliases is not too unusual. Sometimes simply to see them displayed in a standard format. I use them myself sometimes to shorten the names so making qualifying field references easier.

Point taken, even done the latter myself, but in this case, just seemed no make it more complicated (was just a comment) !!

Cheers


MTB
NeoPa's Avatar
Administrator
 
Join Date: Oct 2006
Location: London - UK
Posts: 15,765
#6: Oct 9 '09

re: Help on Sql in Access and ASP


Quote:

Originally Posted by puT3 View Post

oo..That's mean i should delete the brackets ok...i will try it...thanks...

Not exactly. I assume you're referring to the parentheses when you say brackets. What you need is to ensure they're balanced (opens all have matching closes) rather than to remove them completely.

PS. @MTB - I wasn't trying to criticise - just commenting from one expert to another. Sorry if it came across wrongly.
Reply