automatic joint in QBE example
This commit is contained in:
@@ -9,6 +9,7 @@ $Source$
|
|||||||
* tbl_qbe.php3: automatic joints from Relation table, thanks
|
* tbl_qbe.php3: automatic joints from Relation table, thanks
|
||||||
to Mike Beck (mike.beck at ibmiller.de)
|
to Mike Beck (mike.beck at ibmiller.de)
|
||||||
(experimental: some things remain to be tested)
|
(experimental: some things remain to be tested)
|
||||||
|
* Documentation.html: example for automatic joints
|
||||||
|
|
||||||
2002-04-26 Alexander M. Turek <rabus@users.sourceforge.net>
|
2002-04-26 Alexander M. Turek <rabus@users.sourceforge.net>
|
||||||
* libraries/common.lib.php3: fixed a controluser bug.
|
* libraries/common.lib.php3: fixed a controluser bug.
|
||||||
|
@@ -593,6 +593,10 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
|
|||||||
display links on the table properties page, to check referential
|
display links on the table properties page, to check referential
|
||||||
integrity (display missing foreign keys) for each described key.
|
integrity (display missing foreign keys) for each described key.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
in query-by-example, create automatic joints (see an example
|
||||||
|
in the FAQ, section "Using phpMyAdmin").
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -1533,6 +1537,68 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
|
|||||||
this document.
|
this document.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<b>How can I use the relation table in Query-by-example?</b>
|
||||||
|
<br />
|
||||||
|
Here is an example with the tables persons, towns and countries. Start
|
||||||
|
by creating this: <br /><br />
|
||||||
|
<tt>
|
||||||
|
CREATE TABLE countries (<br />
|
||||||
|
country_code char(1) NOT NULL default '',<br />
|
||||||
|
description varchar(10) NOT NULL default '',<br />
|
||||||
|
PRIMARY KEY (country_code)<br />
|
||||||
|
) TYPE=MyISAM;<br />
|
||||||
|
<br />
|
||||||
|
INSERT INTO countries VALUES ('C', 'Canada');<br />
|
||||||
|
<br />
|
||||||
|
CREATE TABLE persons (<br />
|
||||||
|
id tinyint(4) NOT NULL auto_increment,<br />
|
||||||
|
person_name varchar(32) NOT NULL default '',<br />
|
||||||
|
town_code varchar(5) default '0',<br />
|
||||||
|
country_code char(1) NOT NULL default '',<br />
|
||||||
|
PRIMARY KEY (id)<br />
|
||||||
|
) TYPE=MyISAM;<br />
|
||||||
|
<br />
|
||||||
|
INSERT INTO persons VALUES (11, 'Marc', 'S', '');<br />
|
||||||
|
INSERT INTO persons VALUES (15, 'Paul', 'S', 'C');<br />
|
||||||
|
<br />
|
||||||
|
CREATE TABLE relation (<br />
|
||||||
|
src_table varchar(32) NOT NULL default '',<br />
|
||||||
|
src_column varchar(32) NOT NULL default '',<br />
|
||||||
|
dest_table varchar(32) NOT NULL default '',<br />
|
||||||
|
dest_column varchar(32) NOT NULL default '',<br />
|
||||||
|
PRIMARY KEY (src_table,src_column)<br />
|
||||||
|
) TYPE=MyISAM;<br />
|
||||||
|
<br />
|
||||||
|
INSERT INTO relation VALUES ('persons', 'town_code', 'towns', 'town_code');<br />
|
||||||
|
INSERT INTO relation VALUES ('persons', 'country_code', 'countries', 'country_code');<br />
|
||||||
|
<br />
|
||||||
|
CREATE TABLE towns (<br />
|
||||||
|
town_code varchar(5) NOT NULL default '0',<br />
|
||||||
|
description varchar(30) NOT NULL default '',<br />
|
||||||
|
PRIMARY KEY (town_code)<br />
|
||||||
|
) TYPE=MyISAM;<br />
|
||||||
|
<br />
|
||||||
|
INSERT INTO towns VALUES ('S', 'Sherbrooke');<br />
|
||||||
|
INSERT INTO towns VALUES ('M', 'Montr<74>al');<br />
|
||||||
|
</tt>
|
||||||
|
<br />
|
||||||
|
Then test like this:
|
||||||
|
<ul>
|
||||||
|
<li>Click on your db name in the left frame</li>
|
||||||
|
<li>Choose "Query by example"</li>
|
||||||
|
<li>Use tables: persons, towns, countries</li>
|
||||||
|
<li>Click "Update query"</li>
|
||||||
|
<li>In the fields row, choose persons.person_name and click the
|
||||||
|
"Show" tickbox </li>
|
||||||
|
<li>Do the same for towns.description and countries.descriptions in
|
||||||
|
the other 2 columns</li>
|
||||||
|
<li>Click "Update query" and you will see in the query box
|
||||||
|
that the correct joints have been generated</li>
|
||||||
|
<li>Click "Submit query"</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
|
||||||
<a name="faqproject"></a>
|
<a name="faqproject"></a>
|
||||||
<h3>[phpMyAdmin project]</h3>
|
<h3>[phpMyAdmin project]</h3>
|
||||||
<p>
|
<p>
|
||||||
|
Reference in New Issue
Block a user