Hallo!
Ich weiß dass ich hier in diesem Forum nicht richtig bin, aber ich weiß auch dass hier einige Leute sind, die mir schon oft und sehr gut geholfen haben. Aus diesem Grund stell ich die Frage hier. Also ich habe 2 SQL-Befehle und ich weiß, dass sie richtig sind. Nur arbeite ich auf MySQL und da haben wir schon das Problem. Also erst mal die beiden Befehle:
und
Soweit also mal zu den Befehlen. So jetzt zu den Problem von MySQL. MySQL ist nicht fähig ein UPDATE und SELECT gleichzeitig zu machen:
Das ist mein Problem. Okay, es gibt ein Workaround:
http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/
Aber ich check nicht wie das gehen soll. Kann mir da jemand helfen? Wäre nett. Ich bin nämlich echt schon am Verzweifeln!
Gruß
Buba
Ich weiß dass ich hier in diesem Forum nicht richtig bin, aber ich weiß auch dass hier einige Leute sind, die mir schon oft und sehr gut geholfen haben. Aus diesem Grund stell ich die Frage hier. Also ich habe 2 SQL-Befehle und ich weiß, dass sie richtig sind. Nur arbeite ich auf MySQL und da haben wir schon das Problem. Also erst mal die beiden Befehle:
Code:
sql_Request = "UPDATE test SET ID_Link = ID \
WHERE ID IN (SELECT t1.ID \
FROM test t1, test t2 \
WHERE t1.PACKET_ID = t2.PACKET_ID \
AND t1.DST_IP = t2.SRC_IP \
AND t1.DATE = t2.DATE \
AND (t2.TIME - t1.TIME) <= 5 * 60 \
AND test.TYPE = 'Request')";
Code:
sql_Response = "UPDATE test tt SET ID_Link = (SELECT ID \
FROM test t \
WHERE t.PACKET_ID = tt.PACKET_ID \
AND t.DST_IP = tt.SRC_IP \
AND t.DATE = tt.DATE \
AND (tt.TIME - t.TIME) <= 5 * 60 \
AND t.TYPE = 'Request') \
WHERE ID IN (SELECT t1.ID \
FROM test t1, test t2 \
WHERE t1.PACKET_ID = t2.PACKET_ID \
AND t1.SRC_IP = t2.DST_IP \
AND t1.DATE = t2.DATE \
AND (t1.TIME - t2.TIME) <= 5 * 60 \
AND tt.TYPE = 'Response')";
Soweit also mal zu den Befehlen. So jetzt zu den Problem von MySQL. MySQL ist nicht fähig ein UPDATE und SELECT gleichzeitig zu machen:
Currently, you cannot update a table and select from the same table in a subquery.
Das ist mein Problem. Okay, es gibt ein Workaround:
http://www.xaprb.com/blog/2006/06/23/how-to-select-from-an-update-target-in-mysql/
Aber ich check nicht wie das gehen soll. Kann mir da jemand helfen? Wäre nett. Ich bin nämlich echt schon am Verzweifeln!
Gruß
Buba