473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Automatic joins?

According to the Wikipedia article on PostgreSQL
(http://en.wikipedia.org/wiki/PostgreSQL), it has a feature for
automatic joins:

"SELECT u.* FROM user u, address a WHERE a.city='New York' and
a.user_name=u.user_name

In Postgres the relationship between users and addresses can be
explicity defined. Once defined the address becomes a property of the
user, so the search above can be simplified greatly to:

SELECT * FROM user WHERE address.city='New York'"

Is the a load of nonsense, or am I doing something wrong? I did define a
foreign key, but it doesn't work.

Nov 22 '05 #1
2 1561
I think what is being referred to is that other types can be embedded
directly into the columns of a table. So in the second query the "address"
referred to is a column of the user table, not a table in itself.

I think Postgres may have supported this but PostgreSQL certainly hasn't for
a very long time, if at all. Although apparently it wouldn't be that
difficult to resurrect, just that nobody has done it.

Just think about how it would be returned through the libpq interface if you
did a SELECT * on the table.

Good luck,

On Sat, Jan 17, 2004 at 11:47:18PM +0000, Leif K-Brooks wrote:
According to the Wikipedia article on PostgreSQL
(http://en.wikipedia.org/wiki/PostgreSQL), it has a feature for
automatic joins:

"SELECT u.* FROM user u, address a WHERE a.city='New York' and
a.user_name=u.user_name

In Postgres the relationship between users and addresses can be
explicity defined. Once defined the address becomes a property of the
user, so the search above can be simplified greatly to:

SELECT * FROM user WHERE address.city='New York'"

Is the a load of nonsense, or am I doing something wrong? I did define a
foreign key, but it doesn't work.


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
--
Martijn van Oosterhout <kl*****@svana.org> http://svana.org/kleptog/ (... have gone from d-i being barely usable even by its developers
anywhere, to being about 20% done. Sweet. And the last 80% usually takes
20% of the time, too, right?) -- Anthony Towns, debian-devel-announce


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQFACdpDY5Twig3Ge+YRAp2pAJoCMWcB1r3xNZA7XK8Y6X XkKJJ/PACgsEYC
WZQ9FO9KRWE4wY3qGdmbokk=
=HQeM
-----END PGP SIGNATURE-----

Nov 22 '05 #2
Mensaje citado por Leif K-Brooks <eu*****@ecritters.biz>:
According to the Wikipedia article on PostgreSQL
(http://en.wikipedia.org/wiki/PostgreSQL), it has a feature for
automatic joins:

"SELECT u.* FROM user u, address a WHERE a.city='New York' and
a.user_name=u.user_name

In Postgres the relationship between users and addresses can be
explicity defined. Once defined the address becomes a property of the
user, so the search above can be simplified greatly to:

SELECT * FROM user WHERE address.city='New York'"


I find this totally untrue (un less I missundertud it). Check this out:

siprebi=> select version();
version
---------------------------------------------------------------------------------------------------
PostgreSQL 7.3.4 on sparc-unknown-linux-gnu, compiled by GCC sparc-linux-gcc
(GCC) 3.3.2 (Debian)
(1 row)

siprebi=> select a.nombre from admin a, biblioteca b where b.codigo = 3 and
b.codigo = a.biblioteca;
nombre
--------
(0 rows)

siprebi=> select a.nombre from admin a, biblioteca b where b.codigo = 3;
nombre
-------------------
Andres C. Roman
Martin Marques
Mariano Markowsky
(3 rows)

siprebi=> select a.nombre from admin a where biblioteca.codigo = 3;
NOTICE: Adding missing FROM-clause entry for table "biblioteca"
nombre
-------------------
Andres C. Roman
Martin Marques
Mariano Markowsky
(3 rows)

siprebi=> select a.nombre from admin a;
nombre
-------------------
Andres C. Roman
Martin Marques
Mariano Markowsky
(3 rows)

As you see, no automatic join was performed. Who wrote that article? I see that
example, at least poorly written, if not inaccurate.

--
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-------------------------------------------------------
Martín Marqués | Programador, DBA
Centro de Telemática | Administrador
Universidad Nacional
del Litoral
-------------------------------------------------------

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName,...
4
by: jbm05 | last post by:
Hi, I'm curious about the computational complexity of a query I have. The query contains multiple nested self left joins, starting with a simple select, then doing a self left join with the...
4
by: michaelnewport | last post by:
Greetings, I like to write my inner joins as below, but someone at work tells me its not as 'performant' as using the 'inner join' statement. Is this true ? Is there a better way to write it...
7
by: Steve | last post by:
I have a SQL query I'm invoking via VB6 & ADO 2.8, that requires three "Left Outer Joins" in order to return every transaction for a specific set of criteria. Using three "Left Outer Joins"...
5
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
0
by: Leif K-Brooks | last post by:
I tried posting this before, but I don't think it got posted. Sorry if it did. According to the Wikipedia article on PostgreSQL (http://en.wikipedia.org/wiki/PostgreSQL), it has a feature for...
2
by: anony | last post by:
Maybe this feature is already out there. I guess you could write triggers to do some of this. Often when designing a database I add a start_date and end_date column to the table. The start_date...
2
by: narendra vuradi | last post by:
Hi I have a requirement where in i haev to convert the SQL from Oracle to the one which will run on the SQL server. in the Oracle Query i am doing multiple joins, between some 13 tables. and...
36
by: TC | last post by:
I've used Access for many years. Several times, I've encountered a bug which I refer to as the "Vanishing Joins" bug. When it happens, joins vanish randomly from queries. More specifically, all...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.