Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
248 views
in Technique[技术] by (71.8m points)

php - MySQL update query join and join left

I know basics of mysql and need help in updating query where select query is this:

SELECT f.FinalAmount,f.ActualAmount,fh.ActualPaid,p.Name package,f.FromDate,f.ToDate 
from customers c 
join fees f on f.CustomerID = c.ID 
join packages p on p.ID=f.PackageID 
left join fees_history fh on f.ID = fh.ReferenceID  
where c.ID='108239' and c.branch='664'

I want to update f.FromDate but know know How to do that because the SELECT statement need join query.

question from:https://stackoverflow.com/questions/65881757/mysql-update-query-join-and-join-left

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Directly:

UPDATE 

       customers c 
join fees f on f.CustomerID = c.ID 
join packages p on p.ID=f.PackageID 
left join fees_history fh on f.ID = fh.ReferenceID  

SET f.FromDate = ???

where c.ID='108239' and c.branch='664'

PS. left join fees_history fh on f.ID = fh.ReferenceID does not affect the update and must be removed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...