Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 6th, 2004, 05:38 AM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default delete problem

i have a function that let user to delete a selected brand. For example:
if the user choose brand_id='br45', then i have to
1. find all the prod_id in the product table using the brand_id.
2. delete the selected brand in the brand table using the brand_id.
3. delete the product in the brand table using the brand_id.
4. delete the selected brand's product in price_master using the prod_id found in the first step.
My problem is if the brand's has a few product's in the price_master, how can i delete all of them?
Or can any other ways to do it?
One more question is : is it that i can only delete one row of a table at a time?
CREATE TABLE CATEGORY
(
    CAT_ID INT NOT NULL,
    CAT_NAME VARCHAR(30) NOT NULL,
    PRIMARY KEY (CAT_ID),
) ;

CREATE TABLE BRAND
(
    BRAND_ID VARCHAR(5) NOT NULL,
    BRAND_NAME VARCHAR(30) NOT NULL,
    CAT_ID INT NOT NULL,
    PRIMARY KEY (BRAND_ID),
    FOREIGN KEY (CAT_ID) REFERENCES CATEGORY,
);

CREATE TABLE PRODUCT
(
    PROD_ID VARCHAR(5) NOT NULL,
    PROD_NAME VARCHAR(50) NOT NULL,
    PROD_DESC VARCHAR(20) NOT NULL,
    PROD_PRICE DECIMAL(8,2) NOT NULL,
    PROD_BRAND VARCHAR(5) NOT NULL,
    PRIMARY KEY(PROD_ID),
    FOREIGN KEY(PROD_BRAND) REFERENCES BRAND,
);

CREATE TABLE PRICE_MASTER
(
    PROD_ID VARCHAR(5) NOT NULL,
    START_DATE DATE NOT NULL,
    END_DATE DATE NOT NULL,
    DISKAUN_PRICE DECIMAL(4,2) NOT NULL,
    PRIMARY KEY (PROD_ID),
);

  #2 (permalink)  
Old March 7th, 2004, 07:40 AM
Authorized User
 
Join Date: Oct 2003
Location: KL, wilayah persekutuan, Malaysia.
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No need liao. i solve it already.



Similar Threads
Thread Thread Starter Forum Replies Last Post
entireRow delete problem cronid Excel VBA 2 March 4th, 2008 08:20 PM
Delete query problem aneesh_sunu@yahoo.co.in PHP How-To 2 December 18th, 2006 09:24 AM
problem with delete statement thas123 SQL Server 2000 6 March 23rd, 2006 01:13 PM
Recordset delete question/problem bleutiger Classic ASP Databases 1 February 25th, 2005 07:50 AM
Delete from database problem benskywalker Classic ASP Databases 1 September 26th, 2003 02:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.