T
TB
About a week ago, some of you people kindly assisted me in correcting an SQL
statement whereby a certain number of records where added to one table based
on a data from another table ( name of the thread: "adding records from
another table via SQL").
Now a variation of that theme:
The solution provided last time (thanks a lot):
INSERT INTO newcustomers (customer, customergroup)
SELECT IDcustomer, 7 FROM customers
added a number of records to newcustomers equvalent to the total number of
records in customers. But what if the table customers contains a column
called customercount with values that indicate the number of records to add
to newcustomers in each case?
For example, let's say that
'Select customercount from customers where IDcustomer = 1'
returns the value 2.
How can I create an SQL statement that adds the number of records indicated
in customers.customercount (in this case 2) to newcustomers, adding the
value 7 (as in the previous example) to the column customergroup?
If there are different approaches for Access and MySQL, please let me know
as I have to use this on both databases.
Once again, thanks a bundle for your time.
TB
statement whereby a certain number of records where added to one table based
on a data from another table ( name of the thread: "adding records from
another table via SQL").
Now a variation of that theme:
The solution provided last time (thanks a lot):
INSERT INTO newcustomers (customer, customergroup)
SELECT IDcustomer, 7 FROM customers
added a number of records to newcustomers equvalent to the total number of
records in customers. But what if the table customers contains a column
called customercount with values that indicate the number of records to add
to newcustomers in each case?
For example, let's say that
'Select customercount from customers where IDcustomer = 1'
returns the value 2.
How can I create an SQL statement that adds the number of records indicated
in customers.customercount (in this case 2) to newcustomers, adding the
value 7 (as in the previous example) to the column customergroup?
If there are different approaches for Access and MySQL, please let me know
as I have to use this on both databases.
Once again, thanks a bundle for your time.
TB