SQL database help

mrtorino

New member
Feb 18, 2010
6
0
0
Hi,
I need to make some changes to my database and I was wondering if there is a faster way of doing.

- I have two tables (for example Table1 and Table2)
- Table1 has a field called TF1
- Table2 has two fields called TF2 and TF3

in TF1 there is the following code
<div class="wrap">
XXXXXXXXXXXXXX
XXXXXXXXXXXXXX
</div>
<div class="wrap-two">
YYYYYYYYYYYYYYYYYYYY
YYYYYYYYYYYYYYYYYYYY
</div>

What I'm trying to do is I need to move all the content within <div class="wrap"> to TF2 and move all the content within <div class="wrap-two"> into TF3

So at the end TF1 would be empty, TF2 would have all the content that was previously in div wrap and TF3 would have all the content that was previously in div wrap-two.

to sum up: move all the content within "wrap" from TF1 to TF2 and move all the content within "wrap-two" from TF1 to TF3.

I hope this makes sense.

I have about 2000 entries, so if I was to do this manually it would probably take me a year.
Please let me know if there is some kind of a statement for this.

Thank you in advance.
 


You can do this with regular expressions, looping though the fields. Do T1 and T2 rows have something linking them, maybe an ID?
 
no T1 and T2 have nothing linking them.
The main thing that I'm trying to do is to move the content from within the divs and put them in a new table/fields.

I don't know much about sql. Is there a statement that says
go to Table1 > Field1
look for anything that starts with .... <div class="wrap">
and ends with </div>
and move it to another Table/Field
 
CREATE PROCEDURE curdemo()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE a CHAR(16);
DECLARE b,c INT;
DECLARE cur1 CURSOR FOR SELECT id,data FROM test.t1;
DECLARE cur2 CURSOR FOR SELECT i FROM test.t2;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1;

OPEN cur1;
OPEN cur2;

read_loop: LOOP
FETCH cur1 INTO a, b;
FETCH cur2 INTO c;
IF done THEN
LEAVE read_loop;
END IF;
IF b < c THEN
INSERT INTO test.t3 VALUES (a,b);
ELSE
INSERT INTO test.t3 VALUES (a,c);
END IF;
END LOOP;

CLOSE cur1;
CLOSE cur2;
END;


this was the example
it is a way to define 2 cursors that walk synchrone without index field

DECLARE cur1 CURSOR FOR SELECT id, trim(len (data)0,12)) x, trim(len (data)12,30)) y FROM test.t1;
in your prob you can put table 2 in cursor 2
in the insert into div1.t3 values (x);


I did not lookup mysql syntax just the idea