Stack Exchange
trigger in Mysql cross database
I search and found that mysql accept cross database trigger , I try to write a code below
but look like   bcode.qrcodegen.partnergencode = NEW.partnerTxnUid it accept all value note the one that just insert
USE bcode;
DELIMITER //

CREATE TRIGGER sync_insert AFTER INSERT ON callback 
FOR EACH ROW
BEGIN
INSERT INTO asianonline.sellnote (Code , Pdtail, Paid, Remark, staff)
SELECT bcode.qrcodegen.invoiceid, 'cash', NEW.txnAmount, bcode.qrcodegen.partnergencode, 'bcode'     
FROM      bcode.qrcodegen
LEFT JOIN bcode.callback 
    ON  bcode.qrcodegen.partnergencode = NEW.partnerTxnUid 
    AND NEW.statusCode = '00' 
    AND NEW.errorCode = '00' ;
END; 

//
DELIMITER ; 


Your question is extremely hard to understand.  What exactly is the issue with the above code, and what exactly is your expected result?

it insert many record into asianonline.sellnote , my expect it should insert only one record     I found that it not restrict only the  bcode.qrcodegen.partnergencode = NEW.partnerTxnUid  but bcode.qrcodegen.partnergencode can be any value

This means your select query returns more than 1 rows. We have absolutely no clue how your data looks like, so cannot help you with further details

maybe I should use inner jont

In multi-database environment use complete object names for ALL objects - including the name of the table where the trigger is defined on (i.e. CREATE TRIGGER sync_insert AFTER INSERT ON bcode.callback). Also - single-statement trigger does not need in BEGIN-END and DELIMITER reassigning.

after many try I found this work for me
USE bcode;
DELIMITER //

CREATE TRIGGER sync_insert AFTER INSERT ON callback 
FOR EACH ROW
BEGIN
INSERT INTO asianonline.sellnote (Code , Pdtail, Paid, Remark, staff)
SELECT bcode.qrcodegen.invoiceid, 'cash', NEW.txnAmount, bcode.qrcodegen.partnergencode, 'bcode'     
FROM       bcode.qrcodegen
INNER JOIN bcode.callback 
    ON  bcode.qrcodegen.partnergencode = NEW.partnerTxnUid 
    AND bcode.callback.statusCode = '00' 
    AND bcode.callback.errorCode = '00'
ORDER BY bcode.qrcodegen.id DESC LIMIT 1;
END; 

//
DELIMITER ; 

