I thought I would give this another go. The last person that commented, I could not get their suggestion to work. Maybe I was doing it wrong, I don’t' know. I want to be able to delete multiple records at once. I am building a tool to manage job postings. I want to be able to get a list of properties ($prop) job listings. I want to display the job name ($jobNam) that will be indexed by a unique number in the database ($jobNum). I want a check box next to each listing that they can check for all the jobs they want to delete. I can get the info from the database to make the list of jobs, but I just cant seem to write anything that will actually delete each item checked at once. Any ideas? Thanks, this site rules by the way!
the user will need to submit the form they checked all the jobs they want to delete. You should have some kind of an array.
Build the delete query like:
DELETE FROM jobs WHERE jobnum = array[0] OR jobnum = array[1] .....
jobnum
I was thinking something along the lines of
DELETE FROM TABLE WHERE ID IN (1,2,3,4)
Can anyone confirm or deny this as valid? It's from memory.
that's a good idea. I'm not sure if it will work, but I lean towards yes.
IN is in the comparison operator section in the documentation... the where clause consists of a comparison...
Yup, this should work fine, much quicker as well compared to a multiple and, as it uses a binary search method 🙂