add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE turip_refs (check_id INT, name VARCHAR(5), ref_no CHAR(3));
INSERT INTO turip_refs VALUES
(10, 'alsak', 'xdr'),
(21, 'turin', 'xdr'),
(10, 'tend' , 'ymt'),
(21, 'turin', 'kuy');
SELECT * FROM turip_refs;
check_id name ref_no
10 alsak xdr
21 turin xdr
10 tend ymt
21 turin kuy
SELECT DISTINCT t1.*
FROM turip_refs t1
JOIN turip_refs t2 USING (ref_no)
WHERE t1.check_id != t2.check_id
-- AND another conditions
ORDER BY ref_no
-- , another criteria
check_id name ref_no
21 turin xdr
10 alsak xdr