M
M
magsvx2015-11-25 14:48:31
MySQL
magsvx, 2015-11-25 14:48:31

How to replace values ​​of joined sql tables?

Good afternoon!
There is a SQL database.
I am trying to solve the following issue: it is
necessary to insert the values ​​of the url_flv cell into the direct cell when the value of the uniq_id field in the pm_videos and pm_videos_urls tables matches.
The code:

SELECT pm_videos.url_flv, pm_videos_urls.direct 
FROM pm_videos LEFT OUTER JOIN pm_videos_urls ON pm_videos.uniq_id=pm_videos_urls.uniq_id

It only compares and shows the selected columns.
Help, please, to replace the values ​​of the joined tables.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
nozzy, 2015-11-25
@magsvx

Didn't check:

update pm_videos_urls t1
inner join pm_videos t2
     on t2.uniq_id =  t1.uniq_id   
set t1.direct =  t2.url_flv

M
Max, 2015-11-25
@MaxDukov

UPDATE pm_videos SET url_flv = 'bla-bla-bla' WHERE uniq_id IN (SELECT uniq_id FROM pm_videos_urls)

- this will update the field for all rows for which there is a uniq_id match

A
Artur Polozov, 2015-11-25
@Noxy

www.mysqltutorial.org/mysql-update-join

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question