Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Questions about running nuAddnuID

Questions related to using nuBuilder Forte.
Janusz
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

Unread post 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' ;
If you like nuBuilder, please leave a review on SourceForge
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: Questions about running nuAddnuID

Unread post 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.
Janusz
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

Unread post 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
If you like nuBuilder, please leave a review on SourceForge
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: Questions about running nuAddnuID

Unread post 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'.
Janusz
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

Unread post by Janusz »

so in such case you should use update
https://www.w3schools.com/sql/sql_update.asp
If you like nuBuilder, please leave a review on SourceForge
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: Questions about running nuAddnuID

Unread post by benritter »

Ah yes, UPDATE. sorry to be a silly noob. If it helps, I'm bothering all my programmer friends too.
benritter
Posts: 49
Joined: Wed Aug 26, 2020 10:38 pm

Re: Questions about running nuAddnuID

Unread post 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
Janusz
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

Unread post by Janusz »

Great :D
If you like nuBuilder, please leave a review on SourceForge
Post Reply