topcat1979 Posted November 13, 2006 Share Posted November 13, 2006 ???--------------------------------------------------------------------------------Hi there,I have a site I'm working on which is basically a shopping portal. Within this site I have an area where customers can view there previous purchases, and in this area they can view the product id, price they paid, sellers id, date, etc.I have two tables, shop_users and shop_items. These two tables have some fields in common, one being the seller id, which is a number and is present in both tables under two different field titles; these are: shop_users = id and shop_items = ownerid. To cut along story short I wish to join these two fields, by comparing them in a query and output the result as the username of the seller from the shop_user table.My current code looks a little like this:$getseller="SELECT u.username FROM shop_users u, shop_items a WHERE a.ownerid=u.id";$seller=mysql_query($getseller) I think this is the best way of doing it but unfortunately I have had no luck in getting it to work.If you could point out where I'm going wrong, I'd really appreciate it! ??? Link to comment https://forums.phpfreaks.com/topic/27094-please-help-database-query-to-join-two-tables/ Share on other sites More sharing options...
printf Posted November 13, 2006 Share Posted November 13, 2006 please show the db table scheme for both tables...ThanksSonia Link to comment https://forums.phpfreaks.com/topic/27094-please-help-database-query-to-join-two-tables/#findComment-123884 Share on other sites More sharing options...
topcat1979 Posted November 13, 2006 Author Share Posted November 13, 2006 Sorry away from my machine at the moment, but the basic outline:[b]shop_users[/b]id - numberusername - charname - charsurname - charaddress - charetc[b]shop_items[/b]id - numbertitle - chardescription - charownerid - numberprice - numberetcshop_items['ownerid'] links in with shop_user['id'] Link to comment https://forums.phpfreaks.com/topic/27094-please-help-database-query-to-join-two-tables/#findComment-123891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.