htown — 2010-12-25T19:05:27-05:00 — #1
I am a complete newbie at this and really do not know sql. I am just stumbling around but have completed a few queries with success. I have a field in a table that I want to APPEND information to, specifically the text " 7" (Without the quotes) I am using this:
INSERT INTO jos_vm_product product_sku VALUES ' 7'
But I keep getting an error.
I am using phpMyAdmin
Can anyone offer some help here. This would save me hours of work.
jonmaster — 2010-12-25T19:40:59-05:00 — #2
INSERT INTO jos_vm_product (product_sku) VALUES (7)
htown — 2010-12-25T19:52:25-05:00 — #3
I got this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'RT INTO jos_vm_product (product_sku) VALUES (7)' at line 1
jonmaster — 2010-12-25T20:00:07-05:00 — #4
This is the syntax
INSERT INTO TABLENAME (COLOUMNAME) VALUES (VALUES)
INSERT INTO jos_vm_product (product_sku) VALUES ('7')
are yu sure the table name is correct
htown — 2010-12-25T21:38:52-05:00 — #5
That worked but instead of appending a field in a record it added a whole new record. The filed product_sku was set to 7 and all other fields to NULL. Not was I was wanting to do.
jonmaster — 2010-12-25T22:10:16-05:00 — #6
then u must use update statement
Update tablename set coloumname=value
htown — 2010-12-25T23:52:54-05:00 — #7
Wont this replace what is there? I just need it to append to what is already in the field
jonmaster — 2010-12-25T23:58:18-05:00 — #8
then you should use concatenate for that particular coloumn and row
update tablename set coloumname=concat(coloumname, '7') where id='1';
id is the primary key
htown — 2010-12-26T14:36:33-05:00 — #9
I did a slight modification but it worked. Many many thanks for your help.
update jos_vm_product set product_sku=concat(product_sku, ' 7') where product_id>'106'
I have another thing I am wanting to accomplish it will make a lot more sense to do it using queries than doing through the Virtuemart interface. I have a client that wants to show 50 stone sizes and instead of just putting in all the stones once and using an option to choose one of the four sizes to order, he wants to show 50 stones in a 7mm category, 50 stones in a 8mm category, 50 stones in a 10mm category, 50 stones in a 12mm category. I advised against it but he is insistent. So now since I do not want to enter 150 stones back into the database using the VM admin, I figured there is some way to insert a copy each of the stones back into the database using a query. So basically there will be four of each kind and then I will go back and add 7mm, 8mm, 10mm, and 12mm to the end of the names to show the difference.
Any suggestions on how I would do that?
jonmaster — 2010-12-26T21:59:56-05:00 — #10
Glad it helped, can you ask your second question in a seperate thread