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' ;
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Questions about running nuAddnuID
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Questions about running nuAddnuID
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.
-
- nuBuilder Team
- Posts: 506
- Joined: Fri Dec 28, 2018 1:41 pm
- Location: Krakow, Poland
- Has thanked: 8 times
- Been thanked: 18 times
Re: Questions about running nuAddnuID
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.I don't understand how there is a duplictae when I am only inserting one column into an empty column.
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
If you like nuBuilder, please leave a review on SourceForge
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Questions about running nuAddnuID
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'.
-
- nuBuilder Team
- Posts: 506
- Joined: Fri Dec 28, 2018 1:41 pm
- Location: Krakow, Poland
- Has thanked: 8 times
- Been thanked: 18 times
Re: Questions about running nuAddnuID
so in such case you should use update
https://www.w3schools.com/sql/sql_update.asp
https://www.w3schools.com/sql/sql_update.asp
If you like nuBuilder, please leave a review on SourceForge
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Questions about running nuAddnuID
Ah yes, UPDATE. sorry to be a silly noob. If it helps, I'm bothering all my programmer friends too.
-
- Posts: 49
- Joined: Wed Aug 26, 2020 10:38 pm
Re: Questions about running nuAddnuID
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
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
-
- nuBuilder Team
- Posts: 506
- Joined: Fri Dec 28, 2018 1:41 pm
- Location: Krakow, Poland
- Has thanked: 8 times
- Been thanked: 18 times
Re: Questions about running nuAddnuID
Great 

If you like nuBuilder, please leave a review on SourceForge