Joining one to many relational table

Discussion in 'MCSE' started by =?Utf-8?B?c3FsbGVhcm5lcg==?=, Jun 4, 2005.

  1. I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to join
    Table1 with Table2 and update Table1, but I want to update only 1 for A and 1
    for B in Table1. How will I do it?
     
    =?Utf-8?B?c3FsbGVhcm5lcg==?=, Jun 4, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Mike T. Guest

    "sqllearner" <> schrieb im Newsbeitrag
    news:...
    >I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to join
    > Table1 with Table2 and update Table1, but I want to update only 1 for A
    > and 1
    > for B in Table1. How will I do it?



    Are A,A,B,B,B values for one column across 5 rows in Table1? Are there other
    columns in Table1?

    For the joins, SELECT DISTINCT might be an option. For the update, I need
    more info.

    Also, to use a New York phrase: Not for nothin', but this is the MCSE group.
    You might have a bit more luck with one of the SQLServer groups.

    --
    Mike T.
    MCNGP #XLI
     
    Mike T., Jun 4, 2005
    #2
    1. Advertising

  3. For Table1 the values for column1 is A,A,B,B,B and the correspoding values in
    column2 is 2,2,3,3,3 and the correspoding values in column3 is 0,0,0,0,0. In
    Table2 the values for column1 is A,B and the correspoding values in column2
    is 2,3.

    I want to update Table1.Column3 = 1, where Table1.Column1 = Table2.Column1
    and Table1.Column2 = Table2.Column2. But using joins, I found it updates all
    5 rows in Table1.Column3. But I want to update only 2 rows in Table1.Column3,
    as Table2 has 2 rows. More specifically, I want to update one to one in this
    one to many relational tables.


    "Mike T." wrote:

    > "sqllearner" <> schrieb im Newsbeitrag
    > news:...
    > >I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to join
    > > Table1 with Table2 and update Table1, but I want to update only 1 for A
    > > and 1
    > > for B in Table1. How will I do it?

    >
    >
    > Are A,A,B,B,B values for one column across 5 rows in Table1? Are there other
    > columns in Table1?
    >
    > For the joins, SELECT DISTINCT might be an option. For the update, I need
    > more info.
    >
    > Also, to use a New York phrase: Not for nothin', but this is the MCSE group.
    > You might have a bit more luck with one of the SQLServer groups.
    >
    > --
    > Mike T.
    > MCNGP #XLI
    >
    >
    >
     
    =?Utf-8?B?c3FsbGVhcm5lcg==?=, Jun 4, 2005
    #3
  4. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Guest Guest

    A word of advice:

    What you've described has the look of a pile of string, all colored the
    same, and it seems as though you are asking us to sort it out for you by
    length.

    An image, diagram, or chart would probably help you, or anyone looking to
    help you, to visualize what you are looking to accomplish. Labels other than
    'Table' and 'Column' would also make things somewhat simpler to identify,
    even if they are disguised so as not to give away your intricate little
    conspiracy. Otherwise you will only be spreading confusion and wasting
    people's time.

    If you are looking to spread confusion and waste people's time, I applaud
    your efforts, as you have achieved a great success, albeit limited by your
    choice of publication locale, and the fact that I enjoy wasting my time, so
    you have only achieved a partial waste of my time, which is lame.

    I had to think for you and I claim my $2.50 {?1}.

    Microcephalic S. Bob



    "sqllearner" <> wrote in message
    news:...
    > For Table1 the values for column1 is A,A,B,B,B and the correspoding values
    > in
    > column2 is 2,2,3,3,3 and the correspoding values in column3 is 0,0,0,0,0.
    > In
    > Table2 the values for column1 is A,B and the correspoding values in
    > column2
    > is 2,3.
    >
    > I want to update Table1.Column3 = 1, where Table1.Column1 = Table2.Column1
    > and Table1.Column2 = Table2.Column2. But using joins, I found it updates
    > all
    > 5 rows in Table1.Column3. But I want to update only 2 rows in
    > Table1.Column3,
    > as Table2 has 2 rows. More specifically, I want to update one to one in
    > this
    > one to many relational tables.
    >
    >
    > "Mike T." wrote:
    >
    >> "sqllearner" <> schrieb im
    >> Newsbeitrag
    >> news:...
    >> >I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to
    >> >join
    >> > Table1 with Table2 and update Table1, but I want to update only 1 for A
    >> > and 1
    >> > for B in Table1. How will I do it?

    >>
    >>
    >> Are A,A,B,B,B values for one column across 5 rows in Table1? Are there
    >> other
    >> columns in Table1?
    >>
    >> For the joins, SELECT DISTINCT might be an option. For the update, I need
    >> more info.
    >>
    >> Also, to use a New York phrase: Not for nothin', but this is the MCSE
    >> group.
    >> You might have a bit more luck with one of the SQLServer groups.
    >>
    >> --
    >> Mike T.
    >> MCNGP #XLI
    >>
    >>
    >>
     
    Guest, Jun 5, 2005
    #4
  5. Dear Microcephalic S. Bob,

    You hae already spent 100 words and some valuable (!) time to give advice
    rather than give some idea to sole the problem. The message box do not take
    table formating, thats why I need to explain the values in written format.
    The main thing is that: You donot know the answer and try to blame other
    people for that. Keep silent and do not waste your valuable time, if you
    donot know the answer.
     
    =?Utf-8?B?c3FsbGVhcm5lcg==?=, Jun 5, 2005
    #5
  6. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Guest Guest

    "sqllearner" <> wrote in message
    news:...
    > Dear Microcephalic S. Bob,
    >
    > You hae already spent 100 words and some valuable (!) time to give advice
    > rather than give some idea to sole the problem.


    First, my time is not valuable. I can type 100 words per minute. I slept
    with your mother.

    > The message box do not take
    > table formating, thats why I need to explain the values in written format.


    You're an imbecile. This has nothing to do with a message box. It's about
    the fact that you have minimal to no communication skills, and that's why
    you aren't going to get an answer to your problem. I'll add to this the fact
    that you are in the wrong group to ask such a thing.

    > The main thing is that: You donot know the answer and try to blame other
    > people for that. Keep silent and do not waste your valuable time, if you
    > donot know the answer.


    I could figure out the answer, but you're not entitled to it if you're going
    to try and blame me for the fact that you're too stupid to solve the problem
    on your own instead of going to the wrong newsgroup and providing only
    partial information.

    It's not my job and not my responsibility to answer your problem.

    Now you've made the fundamental mistake of attempting to insult someone who
    was initially on your side, so you're on your own.

    Microcephalic S. Bob
    http://www.roblindman.com - elapsed time, 1 minute
     
    Guest, Jun 5, 2005
    #6
  7. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Herb Guest

    UPDATE Table1 SET Table1.ColumnC = 1 FROM Table1 RIGHT JOIN Table2 ON
    Table1.ColumnA = Table2.ColumnA AND Table1.ColumnB = Table2.ColumnB

    "sqllearner" <> wrote in message
    news:...
    > For Table1 the values for column1 is A,A,B,B,B and the correspoding values
    > in
    > column2 is 2,2,3,3,3 and the correspoding values in column3 is 0,0,0,0,0.
    > In
    > Table2 the values for column1 is A,B and the correspoding values in
    > column2
    > is 2,3.
    >
    > I want to update Table1.Column3 = 1, where Table1.Column1 = Table2.Column1
    > and Table1.Column2 = Table2.Column2. But using joins, I found it updates
    > all
    > 5 rows in Table1.Column3. But I want to update only 2 rows in
    > Table1.Column3,
    > as Table2 has 2 rows. More specifically, I want to update one to one in
    > this
    > one to many relational tables.
    >
    >
    > "Mike T." wrote:
    >
    >> "sqllearner" <> schrieb im
    >> Newsbeitrag
    >> news:...
    >> >I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to
    >> >join
    >> > Table1 with Table2 and update Table1, but I want to update only 1 for A
    >> > and 1
    >> > for B in Table1. How will I do it?

    >>
    >>
    >> Are A,A,B,B,B values for one column across 5 rows in Table1? Are there
    >> other
    >> columns in Table1?
    >>
    >> For the joins, SELECT DISTINCT might be an option. For the update, I need
    >> more info.
    >>
    >> Also, to use a New York phrase: Not for nothin', but this is the MCSE
    >> group.
    >> You might have a bit more luck with one of the SQLServer groups.
    >>
    >> --
    >> Mike T.
    >> MCNGP #XLI
    >>
    >>
    >>
     
    Herb, Jun 6, 2005
    #7
  8. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Guest Guest

    No. He should have used XMLDOM to export the data, which he could have then
    imported through a recordset object and recreated the table with a MAKE
    SHIFT query, and he would be happier if he would have used velveeta instead
    of real cheese.

    Microcephalic S. Bob

    "Herb" <> wrote in message
    news:...
    > UPDATE Table1 SET Table1.ColumnC = 1 FROM Table1 RIGHT JOIN Table2 ON
    > Table1.ColumnA = Table2.ColumnA AND Table1.ColumnB = Table2.ColumnB
    >
    > "sqllearner" <> wrote in message
    > news:...
    >> For Table1 the values for column1 is A,A,B,B,B and the correspoding
    >> values in
    >> column2 is 2,2,3,3,3 and the correspoding values in column3 is 0,0,0,0,0.
    >> In
    >> Table2 the values for column1 is A,B and the correspoding values in
    >> column2
    >> is 2,3.
    >>
    >> I want to update Table1.Column3 = 1, where Table1.Column1 =
    >> Table2.Column1
    >> and Table1.Column2 = Table2.Column2. But using joins, I found it updates
    >> all
    >> 5 rows in Table1.Column3. But I want to update only 2 rows in
    >> Table1.Column3,
    >> as Table2 has 2 rows. More specifically, I want to update one to one in
    >> this
    >> one to many relational tables.
    >>
    >>
    >> "Mike T." wrote:
    >>
    >>> "sqllearner" <> schrieb im
    >>> Newsbeitrag
    >>> news:...
    >>> >I have two tables: Table1 has A,A,B,B,B and Table2 has A, B. I want to
    >>> >join
    >>> > Table1 with Table2 and update Table1, but I want to update only 1 for
    >>> > A
    >>> > and 1
    >>> > for B in Table1. How will I do it?
    >>>
    >>>
    >>> Are A,A,B,B,B values for one column across 5 rows in Table1? Are there
    >>> other
    >>> columns in Table1?
    >>>
    >>> For the joins, SELECT DISTINCT might be an option. For the update, I
    >>> need
    >>> more info.
    >>>
    >>> Also, to use a New York phrase: Not for nothin', but this is the MCSE
    >>> group.
    >>> You might have a bit more luck with one of the SQLServer groups.
    >>>
    >>> --
    >>> Mike T.
    >>> MCNGP #XLI
    >>>
    >>>
    >>>

    >
    >
     
    Guest, Jun 6, 2005
    #8
  9. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Kline Sphere Guest

    >But using joins, I found it updates all
    >5 rows in Table1.Column3.


    maybe you have your joins round the wrong way.....

    Kline Sphere (Chalk) MCNGP #3
     
    Kline Sphere, Jun 7, 2005
    #9
  10. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    FrisbeeĀ® Guest

    "<!-- The F-Word --> <? echo "General Microcephalic S. Bob"; ?> <!--
    Antisocial Interfaces --> // 270-290-291-293-294-298-299" <{
    http://www.planetoftheheads.com/ - head first into the future }> wrote in
    message news:...
    > No. He should have used XMLDOM to export the data, which he could have
    > then imported through a recordset object and recreated the table with a
    > MAKE SHIFT query, and he would be happier if he would have used velveeta
    > instead of real cheese.


    Bate! Everybody knows Velveeta IS real cheese.
     
    FrisbeeĀ®, Jun 7, 2005
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joachim Krais
    Replies:
    2
    Views:
    15,360
    Andre Beck
    Nov 23, 2003
  2. John Ramsden
    Replies:
    0
    Views:
    1,044
    John Ramsden
    Jul 24, 2004
  3. =?Utf-8?B?c3FsbGVhcm5lcg==?=

    Joining one to many relational table

    =?Utf-8?B?c3FsbGVhcm5lcg==?=, Jun 4, 2005, in forum: MCSD
    Replies:
    2
    Views:
    465
    =?Utf-8?B?c3FsbGVhcm5lcg==?=
    Jun 4, 2005
  4. sqllearner
    Replies:
    2
    Views:
    423
    Changgyu Oh
    Jun 9, 2005
  5. sqllearner
    Replies:
    0
    Views:
    277
    sqllearner
    Jun 4, 2005
Loading...

Share This Page