SQL Syntax for MySQL

Posted on 2008-10-06
Last Modified: 2013-12-12
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 = ""
Question by:pda4me
  • 2
LVL 15

Accepted Solution

MMDeveloper earned 500 total points
ID: 22651128
you can issue mutiple statements at a time,, granted this may not be what you want.. in the SQL textarea, just do this

UPDATE affiliates SET IMSLogin = memberNumber WHERE IMSLogin = "";
UPDATE TableB SET IMSLogin = memberNumber WHERE IMSLogin = "";
UPDATE TableC SET IMSLogin = memberNumber WHERE IMSLogin = "";

it will run all 3

Expert Comment

ID: 22651291
  TableB.IMSLogin = TableB.memberNumber
  affiliates.IMSLogin = TableB.IMSLogin
  AND IMSLogin = '';

Expert Comment

ID: 22651296
The above will only work in MySQL - most databases won't allow this.
LVL 59

Expert Comment

by:Kevin Cross
ID: 22651725
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:

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
php string detection problem 7 34
Fulfillment API php code sample 1 40
Why i am getting a star, SSMS does not show me any error. Division Error 5 22
Sql Server group by 10 27
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question