Ich habe zwei Abfragen.sehr seltsames Verhalten auf MySQL-Abfrage
Die erste ist ..
INSERT INTO balik
(balik_date,
balik_time,
balik_cardID,
balik_status,
balik_type)
select
current_date(),
'00:00:00',
L_CardID,
'BELUM BALIK',
L_Type
FROM
logdetail t1
LEFT JOIN balik t2
ON t1.L_CardID = t2.balik_cardID
WHERE
t1.L_Type = 'IN'
and t1.L_Date = current_date()
AND t2.balik_cardID IS NULL"
und ein anderer ist ..
UPDATE balik blk
INNER JOIN logdetail ld
ON blk.balik_cardID = ld.L_CardID
and blk.balik_date = current_date()
SET
blk.balik_status = 'SUDAH BALIK',
blk.balik_type = 'OUT',
blk.balik_time = ld.L_Time
WHERE
ld.L_Type = 'OUT'
and ld.L_Date = current_date()
Mein Problem ist, dass, wenn ich die erste und die zweite Abfrage nichts ausführen passiert, wenn ich nicht alle Datensätze löschen in mein Tisch vorher. In diesem Fall werden beide Abfragen ausgeführt und funktionieren wie ein Charm.
Warum passiert das?
Ich habe bereits meinen Beitrag aktualisiert! –
Sind irgendwelche Spalten Sie einzigartig? Das würde erklären, warum das nur einmal funktioniert. –
auf Tabelle balik (balik_date, balik_time, balik_cardID) sind meine PK und auf Tabelle logdetail (L_Date, L_Time, L_CardID) sind meine PK ... danke für die Antwort .. –