pda4me
asked on
SQL Syntax for MySQL
I am currently using the following SQL statement thru MyPHPAdmin to update records in the table affiliates. How do I make this table perform the same operation on TableB and TableC without re-issuing the command and changing the table name each time?
UPDATE affiliates
SET IMSLogin = memberNumber
WHERE IMSLogin = ""
UPDATE affiliates
SET IMSLogin = memberNumber
WHERE IMSLogin = ""
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The above will only work in MySQL - most databases won't allow this.
For what it is worth, you can create a trigger that after one is updated updates the others if there is a link between the tables. If not, then put the code you accepted in a procedure and so you only ever have to run one statement with memberNumber as parameter.
Here is the syntax on triggers: http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
Here is the syntax on triggers: http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html
affiliates,
TableB
SET
affiliates.IMSLogin=affili
TableB.IMSLogin = TableB.memberNumber
WHERE
affiliates.IMSLogin = TableB.IMSLogin
AND IMSLogin = '';