I have a table where I want to update "time 2" row, in the user's last "time 1" entry. I was try this, but not function.

UPDATE `temp` SET `time2`=NOW() WHERE user = 'kraso' (SELECT max(time1) FROM 'temp')

Recommended Answers

All 5 Replies

That's an odd choice for your forum post. A code snippet is for you to share your final work. If you have a question, use the other styles.

I need a code snippet or at least a screenshot.

Sometimes it helps to go back to the basics: Consider

Update <table name> set <column name> = <value> where <row name> = <row value>;

UPDATE temp SET time2=NOW() WHERE user = 'kraso' AND time1=(SELECT max(time1) FROM temp WHERE user='kraso')

By this Query , required data is fetched!!

UPDATE temp SET time2=NOW() WHERE  time1 in (SELECT max(time1) FROM temp WHERE user='kraso')
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.