Website Add/delete/change/Chashi Common SQL statements

Source: Internet
Author: User

Recently in the Learning database PHP + MySQL basic crud operation, record the pit for your reference. The SQL statements you need to use in crud are still more, including the following:

    1. Querying all data
    2. Querying a field in a table
    3. Query and sort ascending by ID
    4. New, to pass the parameter in the URL
    5. New, pass through the object parameter
    6. Delete
    7. Page out
    8. Modify

Table structure:

Query and sort by table ID:

// user_id  = "Select*fromORDERbyuser_id";

To query all the data in a table:

   = "select * from ' t_users '"; 

New, the parameter is passed in the URL:

/*get data sent from the client*/$userName=$_get[' user_name ']; $userAge=$_get[' User_age ']; $userSex=$_get[' User_sex '];/*INSERT into table name (column name 1, column Name 2, ...) VALUES (' corresponding data 1 ', ' corresponding data 2 ', ... )*//*values are all strings, because the table property is set to a string*/$sql="INSERT  intoT_users (user_name, User_age,user_sex)VALUES('$userName','$userAge','$userSex')";

Delete, delete according to table ID, bulk Delete:

/**= $_get[' rowId ']= " Delete  from where user_id = ' $rowId '";

Website Add/delete/change/Chashi Common SQL statements

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: 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.