Joining and then ordering by a common column
- From: "MrKrinkle" <yugyug66@xxxxxxxxxxx>
- Date: 23 Aug 2005 16:39:06 -0700
I have mysql 4.0.something (so I can't do subselects).
I think this is a common question:
I have 2 tables, they each have a column called "age" (float not null).
The two tables are in no way related to each other, neither has the
primary of the other.
I want to do one select which gives me every record in both tables,
once. Why would I want that rather than doing two selects? Well I
want to "cross-order" them by age. Like the following:
SELECT * from tableA, tableB ORDER BY age LIMIT 10, 50;
You immediately see the problem. The "age" column is unqualified. But
I WANT it to be unqualified- they both have an "age", and I want get a
list of results sorted by age.
Also, the other problem is I get more results than I want. For every
tableA record, I get every tableB record as well. I know that's the
nature of joining, but that's not what I want. This doesn't seem like
such a wierd thing I'm trying to do here!
.
- Follow-Ups:
- Re: Joining and then ordering by a common column
- From: Stefan Rybacki
- Re: Joining and then ordering by a common column
- Prev by Date: Late Breaking News Submissions due for XML 2005 -- discounts available
- Next by Date: Re: Joining and then ordering by a common column
- Previous by thread: Late Breaking News Submissions due for XML 2005 -- discounts available
- Next by thread: Re: Joining and then ordering by a common column
- Index(es):
Relevant Pages
|
|