Help with an updatequery!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Trying to create a query where I need move data from one textfield in one
table to another textfield in another table.

The from table is called TblPath and contains one record only, and it has a
field called PicturePath1.

I want to move the data to a table called Master and a field called
PictureName1.

It is important that the data from PicturePath1 ends up in PictureName1 from
the left and then directly without any space between will the origianal data
in Picturename1 be.

Hope this is possible to do.

Thank you in advance

Mattias
 
Mattias:

This should do it:

UPDATE Master, TblPath
SET Master.PictureName1 =
TblPath.PicturePath1 & Master.PictureName1;

By including both tables in the query but without any JOIN clause or any
join criterion in a WHERE clause it returns the Cartesian Product of the two
tables, i.e. every row in one is joined to every row in the other. As
TblPath only has one row, however, the number of rows returned the same as
that in master, with the same value from Tblpath concatenated to the existing
value of the PictureName1 column in each row.

However, why do this at all? By concatenating the values in a computed
column in a query you can return exactly the same values in its result set:

SELECT TblPath.PicturePath1 & Master.PictureName1
AS FullPath
FROM Master, TblPath;

You can of course also include other columns from Master in the SELECT
clause of the query.

Ken Sheridan
Stafford, England
 
Back
Top