table join
| From: | David McGlone | Date: | Tue, 04 Sep 2012 22:27:43 +0000 |
| Subject: | table join | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-48461@lists.php.net to get a copy of this message | ||
Hi everyone
I'm having a whole lot of fun playing with this project. It just keeps
expanding and taking me to new territory and I'm really enjoying it. I got a
quick question though. I've been playing around with table joins and I tried
to join based on the ID but I quickly realized this is not a good solutions,
because the ID's in each table aren't always going to match. This is a simple
join that I was messing around with:
$sql = 'SELECT * FROM inventory, extended_info WHERE inventory.id =
extended_info.id';
So I'm wondering if I should figure a way to always make my ID's in each table
match, which is probably not possible or I'm thinking a unique field for both
tables and use that to match up the records, but I know zilch about cars
(funny considering what I chose to start with) and I couldn't think of 1 thing
that would be unique to match up... LOL so what would be a wise way to go
about this type of thing.
PS I'm not looking for code, just some feedback on logic.
--
Regards
David M.