Re: table join
Karl DeSaulniers <[email protected]>
| Newsgroups | gmane.comp.php.database |
|---|---|
| Message-ID | <[email protected]> |
On Sep 4, 2012, at 5:27 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. > -- > Regards > David M. I think your needing to do something like this. $sql = 'SELECT in.id FROM inventory in, extended_info ex WHERE in.id = ex.id'; Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php