union query and new filed with fixed value

  • Thread starter Thread starter gip500
  • Start date Start date
G

gip500

Is it possible to create a union query between two tables (01 and 02), where
table01 is short of one field, have this field added in the SQL statement
and have assigned to this new field a fixed value?

In may case this new field must the fixed value "No" for all of table01's
records.

(The reason why I need to do so is that because table01 is linked to an
external excel file...)

TIA
Beps
 
Yes: you can add the field to the query, e.g.:
SELECT Field1, Field2, False As MyMissingField, ...
 
Hi, Beps.

Yes. You can add a calculated field to the first SELECT clause so that it
matches the data structure and sequence of the fields in the second SELECT
clause of the UNION query. The syntax would be like this:

SELECT table01.ID, table01.Stuff, "No" AS IsStuffScheduled
FROM table01
UNION
SELECT table02.ID, table02.Stuff, table02.IsStuffScheduled
FROM table02;

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
Back
Top