Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query question
GreyWolf_69 (GreyWolf_69_at_alloymail.com) wrote:
: Hi,
: I was wondering if there was a way to have two different queries in
: a script
: that would write the results to the same line(s) in a file? The two
: queries don't have
: any common keys or fields.
: ex:
: query one: select name, id from emp;
: query two: select city, temp from forcast;
: ex of output that I'm looking for:
: name id city temp
: Don 001 Taos 85
You can use a join with no join'ing where clause
select emp.name, emp.id , forcast.city, forcat.temp from emp,forcast;
This will show all the combinations.
I assume though that you want the somthing like "Don" and "Don's city". Assuming that the employees location is recorded in some other table (for example) in a "travel arrangements" table, then you could add a clause like
WHERE exists (select * from travel_arrangements T where T.name = emp.name and T.city = forcast.city) or use a three way join select * from emp,forcast,travel_arrangements T where emp.name = T.name and forcast.city = T.city;
: TIA,
: Grey
-- Received on Fri Jan 21 2000 - 13:14:47 CST