Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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),
);

Reply With Quote
  #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.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:44 AM.


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