Re: table join
| From: | David McGlone | Date: | Tue, 04 Sep 2012 22:34:03 +0000 |
| Subject: | Re: table join | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48462@lists.php.net to get a copy of this message | ||
On Tuesday, September 04, 2012 06:27:43 PM David McGlone wrote:
> 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.
I don't think I should reply to my own post, but I had a light bulb go off and
I'm thinking maybe I should get the last inserted record and work it from
there. Is that smart?
--
Regards
David M.