Question
UNION SELECT
Hi, I want to do two queries. One query with a combination of
tables and one query in one of the tables where the combination
does not count for [so that all devices will be shown, and not only
devices that will show after the first query, but also devices that
are not being showed in the first query].
The query I made:
SELECT dev.dev_id, dev.dev_volgnr, dev.dev_serie, dev.dev_datum_in, dev.dev_lok, dev.dev_geb, novell.N_ip, novell.N_model, novell.N_mac, novell.N_ram, novell.N_serienr, nds2.NDS_klok, nds2.NDS_serie, nds2.NDS_fab, bios.B_INSTALLDATE, bios.B_SERIALNUMBER, g.geb_code, g.geb_vol
FROM dev, novell, nds2, bios
JOIN gebouw AS g ON g.geb_code = dev.dev_geb
WHERE
dev.dev_serie = novell.N_serienr AND dev.dev_serie = nds2.NDS_serie AND dev.dev_serie= bios.B_SERIALNUMBER AND dev.dev_typenr = 1
UNION
SELECT dev.dev_id, dev.dev_volgnr, dev.dev_serie, dev.dev_datum_in, dev.dev_lok, dev.dev_geb, dev.dev_typenr, dev.dev_jaar, dev.dev_MAC, dev.dev_his, dev.dev_own, dev.dev_user, dev.dev_nr, dev.dev_datum_tr, dev.dev_datum_ac, dev.dev_act, dev.dev_opm, dev.scandate FROM dev WHERE dev_serie NOT IN (#preserveSingleQuotes(seriends)#) AND dev_typenr = 1
You see I use UNION to also let show the data that will not be shown by the first query, however If I want to display this query [theresult]. The first part is being shown good, but the second part not.
For instance I let everything show in a table and in row one I let show:
dev.dev_volgnr, novell.N_ip, etc...
This works fine for the first query, but in the second query it does not find a novell.N_ip, so it just shows something else [dev.dev_typenr].
Is it even possible to combine two different queries with different fields?
Is there another way perhaps?
Hopefully someone can help me with this.
Regads,
Kabbi
The query I made:
SELECT dev.dev_id, dev.dev_volgnr, dev.dev_serie, dev.dev_datum_in, dev.dev_lok, dev.dev_geb, novell.N_ip, novell.N_model, novell.N_mac, novell.N_ram, novell.N_serienr, nds2.NDS_klok, nds2.NDS_serie, nds2.NDS_fab, bios.B_INSTALLDATE, bios.B_SERIALNUMBER, g.geb_code, g.geb_vol
FROM dev, novell, nds2, bios
JOIN gebouw AS g ON g.geb_code = dev.dev_geb
WHERE
dev.dev_serie = novell.N_serienr AND dev.dev_serie = nds2.NDS_serie AND dev.dev_serie= bios.B_SERIALNUMBER AND dev.dev_typenr = 1
UNION
SELECT dev.dev_id, dev.dev_volgnr, dev.dev_serie, dev.dev_datum_in, dev.dev_lok, dev.dev_geb, dev.dev_typenr, dev.dev_jaar, dev.dev_MAC, dev.dev_his, dev.dev_own, dev.dev_user, dev.dev_nr, dev.dev_datum_tr, dev.dev_datum_ac, dev.dev_act, dev.dev_opm, dev.scandate FROM dev WHERE dev_serie NOT IN (#preserveSingleQuotes(seriends)#) AND dev_typenr = 1
You see I use UNION to also let show the data that will not be shown by the first query, however If I want to display this query [theresult]. The first part is being shown good, but the second part not.
For instance I let everything show in a table and in row one I let show:
dev.dev_volgnr, novell.N_ip, etc...
This works fine for the first query, but in the second query it does not find a novell.N_ip, so it just shows something else [dev.dev_typenr].
Is it even possible to combine two different queries with different fields?
Is there another way perhaps?
Hopefully someone can help me with this.
Regads,
Kabbi