How does phpmysqlwhere Delete multiple IDs?

Source: Internet
Author: User
If you delete multiple databases, whereid1orid2orid3 ...... however, the deletion id is assembled by a number. My approach is to traverse and delete the id. Is there a simple way to delete the id without traversing? Include in, notin, BETWEEN in range, not...
If you delete multiple databases, the where id = 1 or id = 2 or id = 3 ......
However, the deletion id is assembled by a number. My approach is to traverse and delete the id.
Is there a simple way to delete without traversing?
There are also in, not in, BETWEEN is in the range, not BETWEEN is not in the range
What do these four mean?

Reply content:

Example
If you delete multiple databases, the where id = 1 or id = 2 or id = 3 ......
However, the deletion id is assembled by a number. My approach is to traverse and delete the id.
Is there a simple way to delete without traversing?
There are also in, not in, BETWEEN is in the range, not BETWEEN is not in the range
What do these four mean?

In (1, 2, 3, 4) is all in the brackets
Not in (,), that is, all the non-conformities in the brackets
Between 9 and 12, that is, 9-12 (9, 10, 11, 12) in this range all match
Not between 12 and 15, that is, 12-15 (,) all do not match

The simplest one is to write it and read the results.

You can delete multiple entries. Since it is encapsulated into an array, you can convert it into a comma-separated string and put it in.

Delete from table where id in (1, 2, 3) # id of 1, 2, 3
Delete from table where id not in (1, 2, 3) # All records except 1, 2, 3

Delete from table where id between 1 and 5 # id 1-3
Delete from table where id not between 1 and 5 # All records except 1-5

Delete from table where id in (1, 2, 3 ))

Convert your array to a string of "1, 2, 3 ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.