I use CodeIgniter and store my batch values as comma-separated values in the batch column of my schedule table. For example, a batch value might be 123,234.
My query:
$batch = 123;
$lot = 1;
$dataTest = $this->db->query(
"SELECT q_set FROM schedule WHERE lot='$lot' AND batch='$batch'"
)->row();
See my image below
I try to select one value and match my sent value.
How to match both conditions in the WHERE clause?
You can also use FIND_IN_SET(), because it is used to find a whole match within a comma-separated value.
$this->db->select('q_set');
$this->db->from("schedule");
$this->db->where("FIND_IN_SET('$lot', lot)");
$this->db->where("FIND_IN_SET('$batch', batch)");