Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Inserting field info from one table into another


jwsfun

Recommended Posts

I'm not sure if this is the right forum, but I'll ask anyway...

 

How do I get a customers name and email address (from the customers_table) to show in another table? How do I join them? Is that the correct way?

 

In other words, is it possible to query a customers_name and customers_email_address from the customers_table AND customers_id used in a second table, and THEN display the rest of the columns from the second table?

 

I've entered the new fields, "customers_name" and "customers_email_address" into a table, but don't quite know how to get the php code to do this.

Link to comment
Share on other sites

I'm not sure what you want to do. If you just want to have a query return data from two tables, that's not difficult. For example, if you want to return a list of orders with the customer's last name you could do something like

$ocne_query = tep_db_query("select c.customers_lastname, o.* from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS . " o where o.customers_id = c.customers_id");

This would be a straight join.

 

Hth,

Matt

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...