Practical sql statement

1.select into and insert into select and use the difference between
the SELECT * INTO destTbl from srcTbl
INSERT INTO destTbl (fld1, FLD2) the SELECT fld1, 5 from srcTbl
more than two srcTbl of all the data into the destTbl, but there are two differences of.
    The first sentence (select into from) requires that the target table (destTbl) does not exist, because it will be created automatically upon insertion. (Insert under into, the result is a good choice to set a table insertion within an existing
    second sentence (insert into select from) requires that the target table (destTbl) exists, because the destination table already exists, so apart from the source table is inserted outside (srcTbl) fields, constants can also be inserted
in the preservation select * into is a selected set of results to a table that will be created.
2. use insert into select from statement with the replication target tables and data source tables already exist, to be interpolated schema temporary table to and inserted into the source consistent column corresponding column, a data type corresponding to the data type.
the iNSERT the INTO title (the title_id, title, type, the pub_id)
the SELECT the title_id, title, type, the pub_id
the FROM the titles the WHERE (pub_id = '0766')
3.In use
  /// delete the selected classroom information
  void DeleteSelected public (the ArrayList Selected)
  {String delWhere = "in ID (";
      the foreach (int ID in Selected)
        {
            delWhere ID = + + ",";
        }
        delWhere delWhere.Substring = (0, delWhere.LastIndexOf ( "," ));
        delWhere = + ")";
        dal.DeleteByWhere (delWhere);
  }
is equivalent to: Delete from Student WHERE ID in ( '. 1', '2', '. 3')
4.substring (expression, the starting position intercept length) usage (1 starts from the starting position)
the SELECT *
the fROM bjsjk WHERE jw_xybh = 'a' and jw_sszybh = '100 302' and (Cast (the substring (BH, 1,2) AS int) an xz +) = 06


Reproduced in: https: //www.cnblogs.com/hubcarl/archive/2009/03/15/1412711.html

Guess you like

Origin blog.csdn.net/weixin_33984032/article/details/93817096