What I've done in situations like this is write SQL that generates the SQL I
need. I then pipe out to a file and pipe it back in, or just pipe from one
instance of mysql to another.
Example SQL:
SELECT
CONCAT('UPDATE main SET ', field, ' = ', id, ';')
AS update_sql
FROM map
Example command to accomplish on one step:
mysql -u user -ppass -D db -e "the above sql" | mysql -u user -ppass -D db
HTH,
Dan
On 6/27/07, Mogens Melander <[EMAIL PROTECTED]> wrote:
Hi all,
I'm trying to wrap my brain around folowing problem.
table main(code, field_1, field_2, field_3, , , field_51)
111, 'X', '', 'X',,,
222, '', '', 'X',,,
333, '', 'X', '' ,,,
444, '', '', '' ,,,
555, 'X','X', '' ,,,
table map(id, field)
1, 'field_1'
5, 'field_2'
9, 'field_3'
....
....
86, 'field_51'
The exercise is: replace 'X' with map.id in main.<map.field>
main.code and map.id are primary keys, all other are varchar.
Hmm, did that make any sense?
--
Later
Mogens Melander
+45 40 85 71 38
+66 870 133 224
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]