Y
Y
Yuri Denisov2014-01-18 08:43:19
MySQL
Yuri Denisov, 2014-01-18 08:43:19

How to populate a base based on another base?

Good day to all! Help how to automatically fill in one field using sql based on another database.
There is a sales table, the client_id field has been added to it, where you need to write the client id from the clients table. In the sales table, each client was previously driven in by hand, respectively, the client field in sales and name in clients are the same. It is necessary to scan the sales table and put down the client_id everywhere, depending on who the client is. How to do it automatically?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2014-01-18
@Papagatto

On t-sql it will look something like this

update s set s.client_id = cl.id
from sales s inner join clients cl on s.client = cl.name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question