MySQL Forums
Forum List  »  General

Doubt on a query
Posted by: Eduardo Luis
Date: February 19, 2021 09:11AM

Hi... I have 2 tables
One table, called FichaClientes contains several fields including user_id,name,last_date, etc...

The other table is called Calendar and has severall entries from the user_id and all days that user_id was present - it has fields like calendar_id, user_id, day, etc....

The field last_date on the first table was created a few days ago and I'm updating it while entries are inserted on Calendar.

But I have thousands of records that the last_date is empty and I want to populate with the last day of that user_id.

Table1 - FichaClientes
user_id;name;last_date
1;John;0000-00-00
2;Boo;0000-00-00
3;Mary Ane;0000-00-00

Table2 - Calendar
calendar_id,user_id,day
1;2;2019-01-15
2;2;2019-08-04
3;1;2017-08-25
4;1;2021-01-15

So...
I want to update table1 (FichaClientes) according to the last date of Calendar
It would be:
user_id;name;last_date
1;John;2021-01-15
2;Boo;2019-08-04
3;Mary Ane;0000-00-00

What is the fastest query and preferably with an UPDATE statement?

Thank you

Options: ReplyQuote


Subject
Written By
Posted
Doubt on a query
February 19, 2021 09:11AM
February 19, 2021 12:23PM
February 22, 2021 03:02AM
February 22, 2021 03:13AM
February 22, 2021 11:03AM
February 22, 2021 11:09AM
February 22, 2021 09:33PM
February 23, 2021 06:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.