Results 1 to 11 of 11
  1. #1
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130

    Unanswered: update the column default (relation)

    i want a query that insert a data into the column
    let me explain clearly i has a table for example


    Create table Srikari
    (No int IDENTITY(1,1),
    Members varchar(20) NOT NULL,
    Designation varchar(20) NOT NULL,
    Place varchar(20) NOT Null,
    Year smallint NOT NULL
    )
    insert into srikari Values
    ('Sriram', 'Chief-Secretary','Jillellamudi','2001')
    insert into srikari Values
    ('Hema kumar','President','Hyderabad','2001')
    insert into srikari Values
    ('Bhushan','Secretary','Vijawada','2001')
    insert into srikari Values
    ('Bharavi','Vice-President','Vizag','2001')
    insert into srikari Values
    ('Pardhu','Treasurer','Bapatla','2001')
    insert into srikari Values
    ('Vamsi','Member','Ongole','2001')
    insert into srikari Values
    ('Kashyap','Member','Bapatla','2001')
    insert into srikari Values
    ('Nageswar','Member','Bapatla','2001')
    .
    .
    .
    .
    drop table srikari


    i want to change the column_Designation "member" = "Partner" when both column_place is bapatla and column_year is 2001
    unable to make a relation plz help
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Show us what you've some up with so far and we'll finish it off. You'll learn more that way rather than we just write it.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130
    Code:
    update column name designation 
    on 
    (Place='Bapatla' and year='2001') as 'partner' from srikari
    like some codes
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Blimey - have you made that up yourself or have you used that syntax with something else?
    UPDATE

    Code:
    UPDATE  srikari
    SET     designation     = 'partner'
    WHERE   Place           = 'Bapatla' 
        AND [year]          = 2001
    BTW - Year is a bad column name. I would change it - with sp_rename
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    Hmm... The answer given makes this problem look more like relational algebra than an actual SQL problem. Having never taken a Relational Algebra class, I could not tell you if that is right or wrong. Are you looking for the SQL statement that would make the change you mentioned above?

  6. #6
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130
    Quote Originally Posted by pootle flump View Post
    Blimey - have you made that up yourself or have you used that syntax with something else?
    BTW - Year is a bad column name. I would change it - with sp_rename
    just i had tried to insert a value which with a relation of both columns yup but failed to do
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

  7. #7
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130
    Quote Originally Posted by MCrowley View Post
    Hmm... The answer given makes this problem look more like relational algebra than an actual SQL problem. Having never taken a Relational Algebra class, I could not tell you if that is right or wrong. Are you looking for the SQL statement that would make the change you mentioned above?
    i just tried to insert data by making a relation but failed trying so the code does not worked i getting errors
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

  8. #8
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Nope - that's neither relational algebra nor relational calculus. I can't remember what the answer would be in either of those, but I know it ain't either of them!
    Testimonial:
    pootle flump
    ur codings are working excelent.

  9. #9
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130
    Quote Originally Posted by pootle flump View Post
    Nope - that's neither relational algebra nor relational calculus. I can't remember what the answer would be in either of those, but I know it ain't either of them!
    i got the answer its so simple but a little bit confuse i know how to write query but i forgetting the commands how can i remember is there any small ways can you help
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

  10. #10
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Yes - study the link and practice. The abstract at the top looks confusing and requires some parsing, but the examples are helpful.

    NOTE that UPDATE in SQL Server has a proprietary FROM clause - this is not portable nor in the standard. If you work in SQL 2008 I would recommend always using MERGE instead, but it will not work in 2005.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  11. #11
    Join Date
    Jul 2010
    Location
    ISHHHH
    Posts
    130
    thanks pootle you are really helpful to me
    WiTh Tnks & ReGaRdS
    mAtHuKuMaLi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •