'LinKin Posted August 20, 2014 Share Posted August 20, 2014 Hello, I'm returning one row of a table by doing the SQL command: SELECT * FROM etc.... As soon as I get the result, I update a column's value of that row; But, I'm doing it this way: UPDATE `myTable` SET `myColumn` WHERE blabla So I'm like searching for the row once AGAIN. How can I avoid this? I mean if I already got the row by doing the SELECT command, how can I update a value of THAT row without making ANOTHER search? Thanks. Link to comment
kidvnet Posted August 20, 2014 Share Posted August 20, 2014 actually, I did not totally understand what is your question. But the reason why we usually looking for the row before we update value is to avoid to update value for some rows have the same condition(WHERE blabla). you can do the way u said ,UPDATE `myTable` SET `myColumn` WHERE blabla. just make sure that 'where' condition only get one single row. Link to comment
'LinKin Posted August 20, 2014 Author Share Posted August 20, 2014 It does. I mean, when you do SELECT, you get the row (after searching into the table) Then if I want to update a value of this row, according to my code, I would be searching into the table again for finding the row that I had already found in the previous step. So the question is how can I avoid making a search into the table AGAIN in order to UPDATE a value? Link to comment
kidvnet Posted August 20, 2014 Share Posted August 20, 2014 well, there should be some way to do that. but I do not know. what I can say ,based on my personal understanding about database,is that the process what you talking about is meanness.the row is a kind of count,not a element or a location of database. so u cannot do anything to the the 'row' you got from 'select' query. however mysql_fetch_assoc function can make a data table from the row which u got from select query. which is fantastic, isn't it Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now