Joining tables that have identical column names
Posted: Thu Aug 16, 2007 8:34 am
Hi,
I'm trying to join tables that have identical column names, but the data within the tables is different. Here's some background info, in case this doesn't make sense. Each table is in the same category (address labels) but from a different vendor. For instance, I'm trying to join tables stacy_addresslabels with donovan_addresslabels (stacy and donovan are the vendors) where both tables have column names product_id, product_name, item_type, vendor, image_name, thumb_name, etc. {If you're wondering why I don't just combine the tables into one, I want to keep them separated for ease of adding/deleting products and for also making it possible to make the webpages for just the one vendor.} Here's an example of the code I was trying to use to combine these tables:
and this:
and this:
I totally know my syntax is wrong (that's why I'm here
). I've searched all over about joining tables, but none of the examples I come across talk about joining tables with the exact same column names. Thanks to anyone who can help this clueless girl out
. I really appreciate it!
Jen
I'm trying to join tables that have identical column names, but the data within the tables is different. Here's some background info, in case this doesn't make sense. Each table is in the same category (address labels) but from a different vendor. For instance, I'm trying to join tables stacy_addresslabels with donovan_addresslabels (stacy and donovan are the vendors) where both tables have column names product_id, product_name, item_type, vendor, image_name, thumb_name, etc. {If you're wondering why I don't just combine the tables into one, I want to keep them separated for ease of adding/deleting products and for also making it possible to make the webpages for just the one vendor.} Here's an example of the code I was trying to use to combine these tables:
Code: Select all
$query = 'SELECT product_name, image_name, vendor FROM donovan_addresslabels, stacy_addresslabels WHERE item_id = ' . $id;Code: Select all
$query = "SELECT COUNT(*) FROM donovan_addresslabels, stacy_addresslabels";Code: Select all
$query = "SELECT thumb_name, product_name, item_id, image_name FROM donovan_addresslabels, stacy_addresslabels LIMIT $start, $display";Jen