[EMAIL PROTECTED] wrote:
> 
> ok, i'm trying to do something like this... and i have no idea how to
> make a query to do this for me.
> 
> i have two tables (just for an example): table1 and table2..
> each one has common fields in it (in this case sourceip, and a date and
> time)
> 
> so for example
> 
> table1:
> sourceip   destip     action        date    time
> 1.2.3.4    3.4.5.6    block         1-1-99  0:0:0
> 
> table2:
> sourceip   destip     request       date    time
> 1.2.3.4    3.4.5.6    /cgi-bin/phf  1-1-99  0:0:1
> 
> what i'd like... is a kind of "concatenation" of these two tables.  for
> example, if i wanted all sourceip=1.2.3.4 sorted by time i should get:
> 
> result:
> sourceip   destip     action    request       date    time
> 1.2.3.4    3.4.5.6    block     NULL          1-1-99  0:0:0
> 1.2.3.4    3.4.5.6    NULL      /cgi-bin/phf  1-1-99  0:0:1
> 
> i have no idea how to go about this. i've experimented with all types
> of joins but i just can't seem to get exactly what i want.
> 
> is this even possible to do in a sql statement? or will i have to do the
> processing in my application?
> 
> (i'm using mysql 3.22.14)
> 
> thanks
> --
> Jason Garman                                         http://garman.nws.net/

Hi Jason

It is possible but not with one Query.

You have to create a temporary table with the union of the columns of both tables.
Then do:
INSERT INTO tempTable (sourceip,destip,action,date,time) SELECT * FROM table1;

INSERT INTO tempTable (sourceip,destip,request,date,time) SELECT * FROM table2;

SELECT * FROM tempTable ORDER BY date, time;

That's it :)

Tschau
Christian

-----------------------------------------------------------
Send a mail to [EMAIL PROTECTED] with
unsubscribe mysql [EMAIL PROTECTED]
in the body of the message to unsubscribe from this list.

Reply via email to