I have 3 tables in a database,
Table 1 4 fields
ID = incremental
datetime = datetime
from = numeric
pin = numeric
Table 2 7 fields
ID = incremental
address1 = text
address2 = text
town = text
county = text
postcode = text
pin = numeric
Table 3 many fields selected a few
ID = incremental
address1 = text
address2 = text
town = text
county = text
postcode = text
datetime = datetime
what I need is a query that as a new record is updated in table 1 it goes to
table 2 matches the columns 'pin' and then creates a new entry in table 3
using the address fields.
Anyone help?
Thanks in advance
SimonSimon Gare wrote:
> I have 3 tables in a database,
> Table 1 4 fields
> ID = incremental
> datetime = datetime
> from = numeric
> pin = numeric
> Table 2 7 fields
> ID = incremental
> address1 = text
> address2 = text
> town = text
> county = text
> postcode = text
> pin = numeric
> Table 3 many fields selected a few
> ID = incremental
> address1 = text
> address2 = text
> town = text
> county = text
> postcode = text
> datetime = datetime
>
> what I need is a query that as a new record is updated in table 1
"New" record "updated"? Do you mean inserted?
it goes to
> table 2 matches the columns 'pin'
with what?
and then creates a new entry in table 3
> using the address fields.
Why are you duplicating data in your database?
Why are you using reserved words for your field names? (datetime)
Are you really using the "text" datatype for the fields above?
Mike Brind|||Use trigger should do the job.
Put a insert trigger on table 1 that insert table 2. On table 2 you
put another insert trigger that insert table 3.
Is it what you want?
Mel
Sunday, March 11, 2012
compare merge and insert
Labels:
compare,
database,
datetimefrom,
fieldsid,
incrementaladdress1,
incrementaldatetime,
insert,
merge,
microsoft,
mysql,
numericpin,
numerictable,
oracle,
server,
sql,
table,
tables
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment