List:General Discussion« Previous MessageNext Message »
From:obed Date:January 24 2008 4:49am
Subject:Re: executing query from the command line -- need help
View as plain text  
On Jan 23, 2008 2:36 PM, Jay Blanchard <jblanchard@stripped> wrote:
> [snip]
> Hello Jay. Thanks for your reply but where is your solution to my
> problem. I'm lost here. Help me -- please
>
> Thx
>
>
> -----Original Message-----
> From: Jay Blanchard [mailto:jblanchard@stripped]
> Sent: Wednesday, January 23, 2008 11:29 AM
> To: Brown, Charles; mysql@stripped
> Subject: RE: executing query from the command line -- need help
>
> [snip]
> SELECT SYS_ID, SYS_LOCATION, SYS_IP FROM PROD_SERVER;
>
> UPDATE TEST_SERVER
> SET SYS_ID  = &value passed from above
>       SYS_LOCATION = &value passed from above
>        SYS_IPADDRESS = &value passed from above;
>
> [/snip]
>
> And here http://dev.mysql.com/doc/refman/5.1/en/user-variables.html
> [/snip]
>
> Always reply to all so that this goes back to the list. I found this in
> my junk folder.
>
> When you retrieve the value from the first query assign that value to a
> variable which can then be used in the second query.
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
>
>


I'm going to propose you a horrible solution:


mysql> select * from table1;
+------+------+
| id   | text |
+------+------+
|    1 | one  |
|    2 | two  |
+------+------+
2 rows in set (0.00 sec)

mysql> select * from table2;
+------+------+
| id   | text |
+------+------+
|    1 | one  |
+------+------+
1 row in set (0.00 sec)

mysql> update table2 set id=(select id from table1 where id=2),
text=(select text from table1 where id=2) where id=1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from table2;
+------+------+
| id   | text |
+------+------+
|    2 | two  |
+------+------+
1 row in set (0.00 sec)


Take care, greetings.
-- 

http://www.obed.org.mx
Thread
Did NOT condition on VARCHAR change with 5.0.45?Mont McAdam15 Jan
  • Re: Did NOT condition on VARCHAR change with 5.0.45?Martijn Tonies15 Jan
    • Re: Did NOT condition on VARCHAR change with 5.0.45?Moon's Father16 Jan
Re: Did NOT condition on VARCHAR change with 5.0.45?Mont McAdam23 Jan
  • RE: Did NOT condition on VARCHAR change with 5.0.45?Jerry Schwartz23 Jan
  • Re: Did NOT condition on VARCHAR change with 5.0.45?Perrin Harkins23 Jan
    • executing query from the command line -- need help Charles Brown23 Jan
      • RE: executing query from the command line -- need help Jay Blanchard23 Jan
      • RE: executing query from the command line -- need help Jay Blanchard23 Jan
RE: executing query from the command line -- need help Jay Blanchard23 Jan
  • Re: executing query from the command line -- need helpobed24 Jan
    • RE: executing query from the command line -- need helpCharles Brown24 Jan