Re: [PHP-DB] grabbing from multiple tables

[email protected] (Peter Lind)
Newsgroups php.db
Message-ID <[email protected]>
On 30 April 2010 12:02, Karl DeSaulniers <[email protected]> wrote:
> Hello All,
> I have a product database. In that database there are several tables dealing
> with individual products.
> I am wanting to set up an editProduct and a productInfo page. For the bulk
> info, I am fine.
> For the product options, I need some guidance.
>
> I have 4 tables dealing with the options.
>
> Product table = main product table where productID is set
> Product Options table = table to store product option info. Where productID,
> optionID and OptionGroupID are stored together per ProductID.
>
> Option Groups table = general option groups EG: Size, Color. Where
> OptionGroupID and OptionGroupName is set.
> Options table = general options EG: Large, Medium, Small, Red, Blue, etc.
> Where OptionID and OptionName is set per OptionGroupID.
>
>
> Is there a way for me to call all these tables when adding a product? edit
> product? view product?

MySQL will only allow you to insert into one table at a time. You can
however update several tables at the same time - see
http://dev.mysql.com/doc/refman/5.0/en/update.html

You can select values form multiple tables with the SELECT syntax:
SELECT table1.blah, table2.blah FROM table1, table2 WHERE table1.id =
table2.foreign_key;

Regards
Peter


-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.