Alternative to UNION?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Alternative to UNION?

Post by tstimple »

Being a newbie, I'm not sure if I am making this more difficult than it really is or if I'm even going about this correctly...

Lets say I have table1 like this:


| CARS | TYPE |
*****************
| CAR1 | 3 |
| CAR2 | 3 |
| CAR3 | 1 |
| CAR4 | 4 |
| CAR5 | 1 |
| CAR6 | 3 |
*****************

Then I have another table2 like this:

| CODE | TYPE |
*****************
| 1 | FORD |
| 2 | CHEVY |
| 3 | DODGE|
| 4 |TOYOTA|
| 5 | BUICK |
*****************

I want to query those two tables and return:

FORD
DODGE
TOYOTA

(i.e. One of each)

I thought that UNION was the way to go, but alas, I do not have mySQL 4.0

How else might I do such I query?

--Tim
Post Reply