union query and new filed with fixed value

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
 
A

Allen Browne

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

'69 Camaro

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top