Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi friends,
I am writing a sql query for updating value based on the two input values.
The value should be updated only when two inputs are matched.
Please correct this query if i made a mistake.
SQL
update Student_Contact_details 
set Contact_name = @contactname, 
    Contact_Relation = @contactrelation, 
    Phone_number = @phonenumber, 
    Alternative_phone_number = @alternativenumber, 
    Email_id=@emailid, 
    StreetAddress=@streetaddress, 
    City=@city, 
    State=@state, 
    Country=@country, 
    Zipcode=@zipcode, 
    Update_date_time=@updatedatetime 
where Contact_id = @contactid and Student_id = @studentid

Thanks for help in advance.
Posted
v2
Comments
[no name] 13-Aug-12 10:46am    
And how exactly are we to know "if i made a mistake"? Does it do what you want? Does it pass validation? Do you get an error?
Christian Amado 13-Aug-12 10:56am    
So, What's the problem here?

Your query will successfully execute. go ahead. Be confident about what you are doing, if you have any problem regarding what you are doing then ask for help. Its not a good habbit to ask to check your problem, no one knows for what you are doing this.

Thanks
Ashish
 
Share this answer
 
You're sentence is correct if you want to update where the two conditions applies.

Regards
 
Share this answer
 
"Please correct this query if i made a mistake" isn't a question.You need to tell whether it works right or wrong? Your code is OK,then you need to see whether it works or not.Any question?See this..
http://www.w3schools.com/sql/sql_update.asp[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900