From: Rick James Date: November 30 2012 12:13am Subject: RE: Update One of Three tables in a single query List-Archive: http://lists.mysql.com/mysql/228743 Message-Id: <582AFBFC517D194489EF570FE21694CF07025924@GQ1-EX10-MB03.y.corp.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Some combo of IN, EXISTS, UNION? It will probably be verbose. > -----Original Message----- > From: Andrew Moore [mailto:eroomydna@stripped] > Sent: Thursday, November 29, 2012 11:32 AM > To: Chris W > Cc: MYSQL General List > Subject: Re: Update One of Three tables in a single query >=20 > What's your use case? I've not heard of a like this done at table/sql > level. >=20 > You could use stored procedures & dynamic SQL to achieve it though. >=20 >=20 > On Thu, Nov 29, 2012 at 5:44 PM, Chris W <4rfvgy7@stripped> wrote: >=20 > > I have three tables, TableA, TableB, and TableC each has a unique ID > > field, idA, idB, idC respectively each table also has a field called > > 'Status'. The id field is always greater than zero. Now suppose I > have > > three variables A, B, and C. Two of them are zero and the other is > a > > valid ID for the corresponding table. Only I don't know which one. > > Is there a way to write a single update statement that will update > > only the one table that has the matching ID? I have tired a few > > different ideas but none seem worth mentioning here since they all > > either update too many records or don't update any records. > > > > Thanks for the help. > > > > Chris W > > > > -- > > MySQL General Mailing List > > For list archives: http://lists.mysql.com/mysql > > To unsubscribe: http://lists.mysql.com/mysql > > > >