Submit form to database with some column are empty
Hi everyone!
I need some help regarding PHP query. I need to show a data with this query
SELECT * FROM job_register WHERE
accessories_required IS NULL AND job_status IS NULL AND job_assign IS NULL AND job_cancel IS NULL
OR
accessories_required = 'NO' AND job_status IS NULL AND job_assign IS NULL AND job_cancel IS NULL
OR
staff_position = 'Storekeeper' AND job_status = 'Ready' AND job_cancel IS NULL
OR
job_assign IS NULL AND job_status = 'Ready' AND job_cancel IS NULL;
If I compare the data in the database, its already match with the condition in the query but that data still not show up. Can someone help me how should I fix my query?
@faiza I see a lot of AND and OR in you query, which means you most likely have a problems with logical grouping
Try to set the braces in your query, like
SELECT * FROM job_register WHERE
(accessories_required IS NULL AND job_status IS NULL AND job_assign IS NULL AND job_cancel IS NULL)
OR
(accessories_required = 'NO' AND job_status IS NULL AND job_assign IS NULL AND job_cancel IS NULL)
OR
(staff_position = 'Storekeeper' AND job_status = 'Ready' AND job_cancel IS NULL)
OR
(job_assign IS NULL AND job_status = 'Ready' AND job_cancel IS NULL);
I did it just as an example, place it correctly according to your logic