# SQL Question

I'm having trouble with this quetion can anyone help me undestand how to come to come to the answer.

Add a field named Allocation to the Part table. The allocation is a number representing the number of units of each part that have been allocated to each customer. Set all values of allocation to zero. Calculate the number of units of part number KV29 currently on order. Change the value of allocation for part number KV29to this number. Display all the data in the Part table.

ALTER TABLE Part
UPDATE Part
SET Allocation= some number
WHERE PartNum= some number
;
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
I believe the line

is asking for a column that is zero characters big--which I don't think is possible (could be wrong though).

I believe what you want is something more like the following. Please note:  "allocation_table" should be replaced with the name of the table holding the part allocation entries and "part_number" should be replaced with the name of the column in Part and the name of the column in "allocation_table" that represents part number (these may be different between the two tables). The "part_number" field that is inside the parentheses should be replaced with the column name from the "allocation_table"; the field outside of the parentheses should be replaced with the column name from the Part table.
``````ALTER TABLE Part

Go

UPDATE Part
SET Allocation = 0;

Go

UPDATE Part
SET Allocation = (SELECT COUNT(1) FROM [allocation_table] WHERE part_number = 'KV29')
WHERE part_number = 'KV29';
WHERE PartNum= some number;
``````
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
Correction to the last update:
``````UPDATE Part
SET Allocation = (SELECT COUNT(1) FROM [allocation_table] WHERE part_number = 'KV29')
WHERE PartNum = 'KV29';
``````
0
Commented:
You can define a CHAR(0) but such a field can only store an empty string or NULL. Which does not appear to suit the requirement you describe.
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.