SQL category update code

What would be a code to update a catory field if a specific name is in the item description line, For example if the description contains Brandy set the item's category to brandy ?

thanks Robert

Reply to
Robert
Loading thread data ...

Robert - first you'll need to know what categoryID has been assigned to your brandy department - run the following query

select * from category

then jot down the ID of the "brandy" category... lets say the ID is 3

your update query will be

UPDATE ITEM SET CATEGORYID = 3 WHERE DEPARTMENT LIKE '%BRANDY%';

the % sign allows for any word before and after the word brandy in the description field...

BACKUP FIRST...!

"Robert" wrote:

Reply to
convoluted

As this is already described by Mr. Convoluted that you must verify whether you have the department created as brandy or not if not first create the department then you and update the departmentID in item table.

Unfortunatelly the query send by Convoluted won't work there is minor change in this and here is this:

Update item Set DepartmentID = Department.ID From Department Where Department.Name like '%Brandy%'

As the query given to you does not have the department table also the department is being checked but category is being updated. so above query is correct one which help you.

"Robert" wrote:

Reply to
Akber Alwani

Reply to
convoluted

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.