Friday, March 23, 2012

Newbie question

I would like to know how to be able to insert into one table for example and
have that table linked to another table.
For example, I have a Wrrok Order system VIA the Web, what happens is
someone will create a work order, and the records are created. I would like
to be able to dynamically add notes to it so that whenever a note is added
to a certain work order, it is added into a second table with a record
called notes (I have primary Keys on both Tables called "wo_id")
Then we I retrieve the Work Order using the Primary Key I want it to display
all of the notes in the secondary table related to that Primary Key.
Any help would be great, thanks and let me know if I did not ask it
correctly!> For example, I have a Wrrok Order system VIA the Web, what happens is
> someone will create a work order, and the records are created. I would
like
> to be able to dynamically add notes to it so that whenever a note is added
> to a certain work order, it is added into a second table with a record
> called notes (I have primary Keys on both Tables called "wo_id")
Just execute an INSERT statement with the wo_id for the work order and the
note for the second column.
> Then we I retrieve the Work Order using the Primary Key I want it to
display
> all of the notes in the secondary table related to that Primary Key.
Either first select the relevant columns from the WorkOrder table and
another SELECT that select the relevant columns from the other table.
SELECT col1, col2...
FROM WorkOrder
WHERE wo_id = ...
SELECT col1, col3
FROM SecTable
WHERE wo_id = ...
Or, do a join:
SELECT wo.col1, wo.col2, sec.col1, sec.col2
FROM WorkOrder AS wo INNER JOIN SecTable AS sec ON sec.wo_id = wo.wo_id
WHERE wo_id = ...
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"JC" <Josh@.Network-Medics.Com> wrote in message
news:uWTMO8JpDHA.2188@.TK2MSFTNGP11.phx.gbl...
> I would like to know how to be able to insert into one table for example
and
> have that table linked to another table.
> For example, I have a Wrrok Order system VIA the Web, what happens is
> someone will create a work order, and the records are created. I would
like
> to be able to dynamically add notes to it so that whenever a note is added
> to a certain work order, it is added into a second table with a record
> called notes (I have primary Keys on both Tables called "wo_id")
> Then we I retrieve the Work Order using the Primary Key I want it to
display
> all of the notes in the secondary table related to that Primary Key.
> Any help would be great, thanks and let me know if I did not ask it
> correctly!
>|||Thanks!
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:evoRiLKpDHA.372@.TK2MSFTNGP11.phx.gbl...
> > For example, I have a Wrrok Order system VIA the Web, what happens is
> > someone will create a work order, and the records are created. I would
> like
> > to be able to dynamically add notes to it so that whenever a note is
added
> > to a certain work order, it is added into a second table with a record
> > called notes (I have primary Keys on both Tables called "wo_id")
> Just execute an INSERT statement with the wo_id for the work order and the
> note for the second column.
>
> > Then we I retrieve the Work Order using the Primary Key I want it to
> display
> > all of the notes in the secondary table related to that Primary Key.
> Either first select the relevant columns from the WorkOrder table and
> another SELECT that select the relevant columns from the other table.
> SELECT col1, col2...
> FROM WorkOrder
> WHERE wo_id = ...
> SELECT col1, col3
> FROM SecTable
> WHERE wo_id = ...
> Or, do a join:
> SELECT wo.col1, wo.col2, sec.col1, sec.col2
> FROM WorkOrder AS wo INNER JOIN SecTable AS sec ON sec.wo_id = wo.wo_id
> WHERE wo_id = ...
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:
>
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
>
> "JC" <Josh@.Network-Medics.Com> wrote in message
> news:uWTMO8JpDHA.2188@.TK2MSFTNGP11.phx.gbl...
> > I would like to know how to be able to insert into one table for example
> and
> > have that table linked to another table.
> >
> > For example, I have a Wrrok Order system VIA the Web, what happens is
> > someone will create a work order, and the records are created. I would
> like
> > to be able to dynamically add notes to it so that whenever a note is
added
> > to a certain work order, it is added into a second table with a record
> > called notes (I have primary Keys on both Tables called "wo_id")
> >
> > Then we I retrieve the Work Order using the Primary Key I want it to
> display
> > all of the notes in the secondary table related to that Primary Key.
> >
> > Any help would be great, thanks and let me know if I did not ask it
> > correctly!
> >
> >
>

No comments:

Post a Comment