On 9 August 2011 20:31, Chris Stinemetz <chrisstinemetz@xxxxxxxxx> wrote: > Okay. I am pretty new to mysql so this may seem like a ridiculous > question to some people. > > I am trying to use a LEFT JOIN query, but the results I am finding > unusual. For every record occurrence there is for the query, the > results are duplicated by that amount. > > So if there are 3 records from the query results, then the output is 3 > times what I expect.. if that makes sense. > > From what I have researched so far. I believe I may need to add a > foreign key to build the relations between the two tables. > > Based on the query can any tell me the correct way of adding the > foreign key if ,in fact, that is what I need? > > I can provide table structures and information if necessary. > > The query is: > > $posts_sql = "SELECT > store_subject, > store_comments, > store_date, > store_tptest, > store_by, > users.user_id, > users.user_name, > users.first_name, > users.last_name > FROM > stores > LEFT JOIN > users > ON > stores.store_by = users.user_id > WHERE > stores.store_subject = '" . mysql_real_escape_string($_GET['id'])."' > ORDER BY > stores.store_date DESC "; > > The query dump is: > > SELECT store_subject, store_comments, store_date, store_tptest, > store_by, users.user_id, users.user_name, users.first_name, > users.last_name FROM stores LEFT JOIN users ON stores.store_by = > users.user_id WHERE stores.store_subject = 'Noland Park Plaza 3509 S. > Noland Rd' ORDER BY stores.store_date DESC > Is users.user_id unique? -- <hype> WWW: plphp.dk / plind.dk LinkedIn: plind BeWelcome/Couchsurfing: Fake51 Twitter: kafe15 </hype> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php