Query info - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Query info (/showthread.php?tid=82893) |
Query info - pippuccio76 - 08-31-2022 Hi i have a db this is two table : location: -id -name -id_materiale NULL -quantity NULL materiale: - id - code - description I put material in location , how can iknow with a query wich material is not present in every location with a query or a model ? RE: Query info - ngatcharius - 08-31-2022 Hi Pippuccio76 SELECT * FROM material WHERE id NOTIN (SELECT id_materiale FROM location) in this query, it will select first all id_material that is in a location and it will select all material that not match the provide id. Hope it help. RE: Query info - pippuccio76 - 08-31-2022 (08-31-2022, 10:42 AM)ngatcharius Wrote: Hi Pippuccio76 it return 0 rows , this query SELECT id_materiale FROM location return 7 record with id_material and other record with NULL ( I have recently started inserting) EDIT: It work in this way SELECT * FROM material WHERE id NOTIN (SELECT id_materiale FROM location WHERE id_materiale IS NOT NULL) |