Re: grabbing from multiple tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No, please confuse me. I need to know this stuff.

@Peter thanks for that introduction to foreign keys. Since my productoptions table is based off of items in products, optionGroups and options, would I use foreign keys for this?

@DZvonko Thanks for trying to protect me, but I am a big boy. :) Do you have an example of how this JOIN works? Since my productoptions table is based off of items in products, optionGroups and options, would I use JOIN for this? And how?

I am looking for the quickest and easiest obviously, but not against learning the longer and harder. I just really wanted to know how to use the foreign key in a real situation.
If JOIN is a more viable solution, I'm all ears.

Any examples or tutorials someone can send me?

Thanks,

Karl


On Apr 30, 2010, at 6:41 AM, DZvonko Nikolov wrote:

Hi,

don't confuse the guy. Just use JOIN clause and you will be fine.
Check for the right syntax and don't complicate more. He said he
is quite new, so discuss about foreign keys will only confuse him.

Use JOIN and pure SQL and you will be fine.

Cheers
DZvonko

--- On Fri, 4/30/10, Peter Lind <peter.e.lind@xxxxxxxxx> wrote:

From: Peter Lind <peter.e.lind@xxxxxxxxx>
Subject: Re:  grabbing from multiple tables
To: "Karl DeSaulniers" <karl@xxxxxxxxxxxxxxx>
Cc: "php-db@xxxxxxxxxxxxx" <php-db@xxxxxxxxxxxxx>
Date: Friday, April 30, 2010, 12:31 PM

On 30 April 2010 12:26, Karl DeSaulniers <karl@xxxxxxxxxxxxxxx> wrote:
> Thanks Peter.
> So what is the logic behind foreign keys? Why use them?

Constraints. When using, for example, the InnoDB engine in MySQL, you
can set foreign key fields on tables. These ensure that your record
will always be bound to a proper record in the connected table - so,
for instance, you won't find yourself in the situation that you have
deleted a record from table1 but table2 still references the table1
record. Also, they're very useful for tying models together
automatically, as you can deduce relationships between models by
foreign keys, for instance (this is simplified but covers a lot of
cases).

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>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Karl DeSaulniers
Design Drumm
http://designdrumm.com


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux