bilis_money Posted July 12, 2006 Share Posted July 12, 2006 hi, i would like to insert data with "where" condition is this correct codesbelow?[code]$query = "INSERT INTO photos (comments) VALUES ('$comment_tmp') where ID = '91';[/code]I want to insert the $comment_tmp into comments only on ID = 91.Is this correct or wrong?Please correct me if i'm wrong.thank you very much in advance. Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/ Share on other sites More sharing options...
GingerRobot Posted July 12, 2006 Share Posted July 12, 2006 I think you would want to use UPDATE here...$query = "UPDATE photos SET comments='$comment_tmp' WHERE id='91'; Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/#findComment-56672 Share on other sites More sharing options...
wildteen88 Posted July 12, 2006 Share Posted July 12, 2006 You'll want to use an UPDATE statement rather than an INSERT statement. INSERT creates a new row into the database. Where as UPDATE can change fields within an existing row Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/#findComment-56674 Share on other sites More sharing options...
brown2005 Posted July 12, 2006 Share Posted July 12, 2006 yes update Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/#findComment-56676 Share on other sites More sharing options...
bilis_money Posted July 12, 2006 Author Share Posted July 12, 2006 ok, i'll try that thanks! Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/#findComment-56687 Share on other sites More sharing options...
Newbiephper Posted July 12, 2006 Share Posted July 12, 2006 sry to use this post but it will get my point across$query = "UPDATE photos SET comments='$comment_tmp' WHERE id='91';what would happen if you wanted to use the 'id' from one table to update data in tanother table.i.e. u have 2 tablesuser data (this contains id)table x ( you want to update data in this table for that particular user)thx any help Quote Link to comment https://forums.phpfreaks.com/topic/14369-inserting-data-with-where-condition/#findComment-56781 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.