java - SQLite UNION not performing when one resultset is empty -


i have union in sqlite select data 3 rtree's

create table monsters (id int primary key, x int, y int, z int, name text, health int, strength int, regen int, weapon int); create table animals (id int primary key, x int, y int, z int, name text, health int,species int, speed int, drops int, speech int); create table players (id int primary key, x int, y int, z int, name text, health int,uuid text, stamina int, level int); create virtual table rtreeone using rtree(id, startx,endx,starty,endy,startz,endz); create virtual table rtreetwo using rtree(id, startx,endx,starty,endy,startz,endz); create virtual table rtreethree using rtree(id, startx,endx,starty,endy,startz,endz);  create trigger updateone after insert on monsters each row begin insert rtreeone (id, startx,endx,starty,endy,startz,endz) values (new.id, new.x, new.x, new.y, new.y, new.z,new.z);end;  create trigger updatetwo after insert on animals each row begin insert rtreeone (id, startx,endx,starty,endy,startz,endz) values (new.id, new.x, new.x, new.y, new.y, new.z,new.z);end;  create trigger updatethree after insert on players each row begin insert rtreeone (id, startx,endx,starty,endy,startz,endz) values (new.id, new.x, new.x, new.y, new.y, new.z,new.z);end;  1 (select id    rtreeone    startx > 20      , starty > 40      , startz > 11      , endx < 40      , endy < 50      , endz < 44),  2 (select id    rtreetwo    startx > 20      , starty > 40      , startz > 11      , endx < 40      , endy < 50      , endz < 44),  3 (select id    rtreethree    startx > 20      , starty > 40      , startz > 11      , endx < 40      , endy < 50      , endz < 44),  monone (select *    1    join monsters on one.id=monsters.id),  anitwo (select *    2    join animals on two.id=animals.id),  playthree (select *    3    join players on three.id=players.id),  living (     select name,           x,           y,           z,           health    monone   union    select select name,           x,           y,           z,           health    anitwo   union    select name,                 x,                 y,                 z,                 health    playthree) select name,        x,        y,        z,        health living; 

this union performs when there 3 types within range. when 1 type missing in range, resultset returns nothing , complete union of 3 rowsets fail , nothing gets returned, although animals , players in list.

how can refactor query won't kill if 1 resultset of 3 returns nothing?

should use bogus join have dummy value , nulls besides or there better alternatives?

i unwind query bit (hopefully rigth understand want achieve). below query return combined rows matched monsters, animals , players.

select monsters.name, monsters.x, monsters.y, monsters.z, monsters.health   rtreeone 1   join monsters on one.id = monsters.id   one.startx > 20   , one.starty > 40   , one.startz > 11   , one.endx < 40   , one.endy < 50   , one.endz < 44 union   select animals.name, animals.x, animals.y, animals.z, animals.health   rtreetwo 2   join animals on two.id = animals.id   two.startx > 20   , two.starty > 40   , two.startz > 11   , two.endx < 40   , two.endy < 50   , two.endz < 44 union   select players.name, players.x, players.y, players.z, players.health   rtreethree 3   join players on one.id = players.id   three.startx > 20   , three.starty > 40   , three.startz > 11   , three.endx < 40   , three.endy < 50   , three.endz < 44 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -