[RDD] Mysql syntax

Wayne Merricks waynemerricks at thevoiceasia.com
Thu May 10 09:53:02 EDT 2012


So the complicating issue is the fact that the group is stored in the 
CART table where as the PLAY_COUNTER is associated with the CUTS table.

The linking field is that NUMBER in CART is the CART_NUMBER in CUTS.

The easiest way I know how to do this is by an UPDATE via INNER JOIN.  
So for your example you'd do something like the following:

update CUTS
inner join CART on CUTS.CART_NUMBER = CART.NUMBER
set CUTS.PLAY_COUNTER = 0
where CART.GROUP_NAME = 'The Group I want to change'

For testing I suggest picking one CUT_NAME that you want to set to 0 and 
changing the WHERE clause to:

where CART.GROUP_NAME = 'The Group I want to change' and CUT.CUT_NAME = 
'The Cut Name For Testing'

This way you will only update 1 record and you can see whether it worked 
before rolling it out to the whole DB and potentially stuffing something 
up with an untested statement.

You could save the above as an SQL file (although to be fair any old 
text file will work).  Then have a bash script that ran as a cron job.

with the following mysql command:

mysql -u root -pMyBrilliantPassword Rivendell < pathToMySQLFile

Please note I'm not a MySQL expert, I don't know if there is a better 
way to do this as MySQL Joins are quite computationally expensive.

Wayne Merricks
The Voice Asia
0121 522 6080


On 10/05/12 00:39, Jimmy Stinson wrote:
> My mysql script writing abilities are limited.  I found the script to
> set the PLAY_COUNTER to 0 and would like to expand on it to set the
> counter to 0 only in one GROUP or by using a key in one of the CART values.
>
> Thanks for any help,
> Jimmy
> _______________________________________________
> Rivendell-dev mailing list
> Rivendell-dev at lists.rivendellaudio.org
> http://lists.rivendellaudio.org/mailman/listinfo/rivendell-dev

#######################
Scanned by MailMarshal
#######################

############

Attention: 

The information contained in this message is confidential and intended 
for the addressee(s) only. If you have received this message in error 
or there are any problems, please notify the originator immediately.
The unauthorised use, disclosure, copying or alteration of this message
is strictly forbidden. Christian Vision or any of its subsidiaries will
not be liable for direct, special, indirect or consequential damages 
arising from alteration of the contents of this message by a third party
or as a result of any virus being passed on. Please note that we reserve
the right to monitor and read any e-mails sent or received by the 
company under the Telecommunications (Lawful Business Practice) 
(Interception of Communications) Regulation 2000. Christian Vision is 
registered in England as a limited company 2842414 and as a charity 
1031031  

############


More information about the Rivendell-dev mailing list