Subject Natural Joins and SELECT queries
Author Robert DiFalco
Say I have the following two tables:

create table Persistent
(
oid INTEGER NOT NULL,
typeId INTEGER NOT NULL,
PRIMARY KEY ( oid )
);

create table NamedPersistent
{
oid INTEGER NOT NULL,
name VARCHAR(64)
PRIMARY KEY ( oid )
);

I should put a FK from NamedPersistent to Persistent, but for now let's
assume I don't.

Now, let's assume I have 10 related records in both. What is the best
way to performed joined queries on these two tables. I notice that the
following doesn't work.

select Persistent.oid, name
from Persistent, NamedPersistent
where name="foo";

If I have 10 records, I get something like 100 results back. Anyone have
any ideas? So to fix it I do this...

select Persistent.oid, name
from Persistent, NamedPersistent
where Persistent.oid=NamedPersistent.oid and name="foo";

But this makes me realize I can do it any number of ways. Can someone
explain the difference between these variants?

select Persistent.oid, name
from Persistent, NamedPersistent
where Persistent.oid=NamedPersistent.oid and name="foo";

select Persistent.oid, name
from Persistent, NamedPersistent
where Persistent.oid=NamedPersistent.oid and name="foo";

select NamedPersistent.oid, name
from Persistent, NamedPersistent
where NamedPersistent.oid=Persistent.oid and name="foo";

select Persistent.oid, name
from Persistent, NamedPersistent
where NamedPersistent.oid=Persistent.oid and name="foo";

Is there a better way to do these types of queries?

R.