[Zope-DB] Combining 2 tables

Chan YH cyhoong at pc.jaring.my
Tue Aug 5 11:55:03 EDT 2003


I would like to combine 2 sql tables into one using dtml/python script
method.
Person (table) + Company (table) => Contact (table)

Can some give a me a tip?

Thank a lot.

Data Entry Form
============
<dtml-var standard_html_header>
<h2><dtml-var title_or_id></h2>
<form method="post" action="form1_action" enctype="multipart/data">
<table>
   <dtml-in listPerson_sql>
      <tr>
         <td>Name:</td><td><dtml-var first_name>&nbsp;<dtml-var
last_name></td>
         <td><select name="co_name" value="">
                   <dtml-in listCompany_sql>
                      <option value="&dtml-co_name;">&dtml-co_name;</option>
                   </dtml-in listCompany>
             </select>
          </td>
      </tr>
   </dtml-in listPerson>
   <tr>
      <td><input type="submit" value="Submit" name="submit" /></td>
   </tr>
</table>
</form>
<dtml-var standard_html_footer>

Form1_action method
===============
???


SQL method
=========
listCompany_sql:
  select * from company

listPerson_sql
select * from person


Table schema
--------------
CREATE TABLE person
(
first_name        char(20),
last_name         char(20)
);

CREATE TABLE company
(
co_name         char(20),
co_phone        char(20)
);

CREATE TABLE contact
(
first_name        char(20),
last_name         char(20),
co_name           char(20),
co_phone          char(20)
);




More information about the Zope-DB mailing list