Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: sql query question

Re: sql query question

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 21 Jan 2000 11:14:47 -0800
Message-ID: <3888b027@news.victoria.tc.ca>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US