Checking several records at one time if they exist

Results 1 to 2 of 2

Thread: Checking several records at one time if they exist

  1. #1
    Join Date
    Dec 1969

    Default Checking several records at one time if they exist

    Hi, <BR><BR>I have a shopping cart (you know how, in general, the shopping carts works). <BR>A visitor wants to buy something but it didn&#039;t completed the order (when the order is <BR>completed I have a field which is True/False field and it gets updated with True - default is <BR>False). <BR><BR>On another page I have the possibility for the visitor to see his lasts orders including not <BR>completed orders. <BR><BR>If an order is not completed a warning is displayed and a link to "Complete this Order" is <BR>shown. <BR>The orders and the products ordered are stored in two separate tables which have <BR>one-to-many relationship established (those two tables are separate from the tables where <BR>the categories, sub-categories and products are stored. <BR><BR>If I have several products in that not completed order I have a problem: how can I check <BR>if all those products still exists in the products table? <BR><BR>So, I have the link "Complete this Order".When the visitor wants to complete it and clicks <BR>on it he will go to the payment page. <BR>But, before reaching the payment page, I want to check if all those products still exists (or <BR>some of them may exist some not) and redirect the visitor to another page - the Error <BR>page where it will tell him that "This order cannot be completed or can be partially <BR>completed" and show him what products are still available for buying and which not. <BR><BR>If in that order is a single product I know how to handle this but id are more then I don&#039;t <BR>have an idea. <BR><BR>Can somebody give me a direction? <BR>If you need more details I can send the ASP pages involved an the database (are small <BR>files). <BR><BR>Thanks, <BR>Mircea

  2. #2
    Join Date
    Dec 1969

    Default RE: Checking several records at one time if they e

    Hopefully, when you say a product still exists, you mean that the remaining quantities are sufficient and not completely deleting the entry.<BR><BR>The way I would see it is I would have my orders table with the ID&#039;s of products in the product table. Then, when the user would come back to complete a transaction, I would get the product name using an INNER JOIN in my sql statement. Then, its simple to compare quantities.<BR><BR>But, if you are deleting items, your order table will (?) contain a textual description of the product (unnessarily repeated text). Therefore, if you want to know all of the orders, in your sql statement, you will have to do a LEFT or RIGHT JOIN where you list all of your orders and only the products where their description is equal.<BR><BR>Now, to know which still exist, you&#039;d do an INNER JOIN, showing the products and orders that have an equal description. Those products that no longer exist will simply not come up in these query results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts