Page 3 of 3
Re: Questions about running nuAddnuID
Posted: Thu Nov 12, 2020 8:23 pm
by Janusz
it means you try to assign more than one record to uid = r1.
do you have already record with client_id = 'r1' ?
when you execute following what you get?
SELECT * FROM clients WHERE client_id = 'r1' ;
Re: Questions about running nuAddnuID
Posted: Thu Nov 12, 2020 10:51 pm
by benritter
Ok yes that was the case. r1 existed in client_id field from a previous try. But I still can't insert the whole column from the other table. I don't understand how there is a duplictae when I am only inserting one column into an empty column.
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 1:21 am
by Janusz
I don't understand how there is a duplictae when I am only inserting one column into an empty column.
you can not just insert one column with data - you have to ensure that every record is properly defined including all required fields - especially client_id must be defined and must be unique for each single record - otherwise it will not work.
If you want to insert one column to the client table from different table you can use following (but you have to adjust to your table names and structure)
(in example belowe I am importing column names from table newclients to the column day in table clients)
Code: Select all
INSERT INTO client(client_id,day) SELECT concat('x',LEFT(MD5(UUID()),15)), names FROM newclients
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 1:36 am
by benritter
Ok that does put the 'day' information in, but it creates new rows in 'client' for every row in 'csv'. I'm just trying to add the 'day' information to existing rows in 'client'.
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 1:41 am
by Janusz
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 1:52 am
by benritter
Ah yes, UPDATE. sorry to be a silly noob. If it helps, I'm bothering all my programmer friends too.
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 3:59 am
by benritter
And here is the sql that worked:
UPDATE client
JOIN csv ON
client.`first_name`= csv.`CSVFirst`
AND client.`street_address` = csv.`CSVAddress`
AND client.`cell` = csv.`CSVPhone`
SET `day` = `CSVday` WHERE 1
Re: Questions about running nuAddnuID
Posted: Fri Nov 13, 2020 7:42 am
by Janusz
Great
