I have two tables A and B. I want to update rows in Table A depending on the back up data stored in Table B.

Table A = most current table of data
Table B = 5 day old back up of table A

Structure of both Table A and B:

item_id(unique int), item_type(int), enchant(int)

I have a list(array) of 'item_type':

item_type[] = 1, 5, 6, 7, 10

For each row in Table B with item_type == 1, 5, 6, 7, or 10 the script should add 5 + 'enchant' and store this updated data in Table A WHERE TableA.item_id == TableB.item_id.

Please help! =)

If you didn' understand that please ask and I'll try to explain it better. (BTW, this script will be helping an online gaming community of over 2000 users)

I think you want to use the IN operator. The IN operator will take the left variable and check it against a comma delimited list (each item enclosed in single quotes if its a character string, without them otherwise) and return true if its in there. Is this what your looking for?

Update TableA,TableB
Set TableA.enchant = TableB.enchant + 5
TableA.item_id = TableB.item_id
AND TableB.item_type IN (1,5,6,7,10)

To my understanding, it looks like it would do what I need. Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.