Re: updating/altering each field on a table

2004-07-08 Thread Duncan Hill
On Thursday 08 July 2004 09:19, Louie Miranda might have typed:

>
> As you can see, it updates the whole "random" field on the table. What
> i would like to do is, update each and everyone of it. using a random
> program, which i have. Its on my first email.
>

> > ###
> > #!/bin/sh -x
> > for random in `pwgen --no-capitalize -N1`
> > do
> > sleep 0
> > done
> >
> > echo $random
> >
> > for update in $random
> > do
> > echo "update dump set random= '$random' limit 1"|mysql -uroot insert

Logic error.  You need to specify which row to update.

Start with
ROW=0
for random in `pwgen`
do
let ROW=$ROW+1
echo "update dump set random= '$random' WHERE countid=$ROW"|mysql -uroot 
insert
done

Untested, but a quick check of how to do math in shell will help.

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: updating/altering each field on a table

2004-07-08 Thread Louie Miranda
Btw, here are the sample database i have.

mysql> select * from dump;
+-+--+--+
| countid | random   | name |
+-+--+--+
|   1 | theeyahs | randpass |
|   2 | ciuwaise | randpass |
|   3 | ciuwaise | randpass |
|   4 | ciuwaise | randpass |
|   5 | ciuwaise | randpass |
|   6 | ciuwaise | randpass |
|   7 | ciuwaise | randpass |
|   8 | ciuwaise | randpass |
|   9 | ciuwaise | randpass |
|  10 | ciuwaise | randpass |
+-+--+--+
10 rows in set (0.01 sec)

mysql>

As you can see, it updates the whole "random" field on the table. What
i would like to do is, update each and everyone of it. using a random
program, which i have. Its on my first email.



On Thu, 8 Jul 2004 16:18:06 +0800, Louie Miranda <[EMAIL PROTECTED]> wrote:
> Im trying to work on a program that can update each field and insert a
> random value on it. But when i run this program it only updates the
> whole random field.
> 
> Can anyone help me? Im pretty clueless how to work this right. :/
> 
> ###
> #!/bin/sh -x
> for random in `pwgen --no-capitalize -N1`
> do
> sleep 0
> done
> 
> echo $random
> 
> for update in $random
> do
> echo "update dump set random= '$random' limit 1"|mysql -uroot insert
> done
> 
> ## end of script ###
> 
> --
> Louie Miranda
> http://www.axishift.com
> 


-- 
Louie Miranda
http://www.axishift.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



updating/altering each field on a table

2004-07-08 Thread Louie Miranda
Im trying to work on a program that can update each field and insert a
random value on it. But when i run this program it only updates the
whole random field.

Can anyone help me? Im pretty clueless how to work this right. :/

###
#!/bin/sh -x
for random in `pwgen --no-capitalize -N1`
do
sleep 0
done

echo $random

for update in $random
do
echo "update dump set random= '$random' limit 1"|mysql -uroot insert
done

## end of script ###

-- 
Louie Miranda
http://www.axishift.com

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]