Abstract: when using the sybase database, we often use excel to read the content in excel and insert it into the sybase database table, in this process, there are often line breaks in excel (line breaks are not visible). After being imported to a table, there are often different errors caused by line breaks. So how can I quickly remove/x0a directly? First, how to collect/x0a, and then remove/x0a.1. The cabl
1. Adding referencesUsing System.Data;Using System.Data.SqlData;2, established in the database connection, it is recommended to make it a method, convenient multiple use.String SqlConnection = "Data Source =" Note 1 ";d atabase = Annotation 2;uid =" NOTE 3 ";p WD =" Note 4 "; (There are many other ways)can refer to http://www.cnblogs.com/delphinet/archive/2011/06/24/2088765.html3, frequently used objects are: Sqlconnection,sqladapter,sqlcommand, datasets, DataGrid and DataReader, to Sqlconnectio
SQL single table/multi-table query removes duplicate recordsSingle table DistinctMulti-table GROUP byGroup by must be placed before order by and limit, or it will be an error************************************************************************************1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSelect * from where in (select peopl
), variable length, can hold photos, files, etc.
int, integer field. Example: Userage int
float, floating-point data is approximate. Example: Userresults float, the approximate numeric data type used to represent floating-point numeric data.
datetime, Date type. Example: Createdatetime datetime
Bit, Boolean type. Can be set to True is male, false is schoolgirl
If the content is very much, indeterminate length (such as article), can be used: nvarchar (max) 6. Save the tabl
condition is not found, all information is queried. For example, id equals to student. id;# Some, any, all clause query exampleQuery the age information of the students older than the class.Select * from student where cid = 5 and age> all (Select age from student where cid = 3);Select * from student where cid = 5 and age> any (Select age from student where cid = 3);Select * from student where cid = 5 and age> some (Select age from student where cid =
SQL SELECT DISTINCT Statement
Grammar:
SELECT DISTINCT column name from table name using DISTINCT keyword
If you want to select all the values from the company column, we need to use the SELECT statement:
SELECT Company from Orders
To select only a different value from the company column, we need to use the Select DISTINCT statement:
The code is as follows
Copy Code
SELECT DISTINCT Company from OrdersLet's take a look
the right table that do not meet the query conditions. The total outer join is actually a mathematical set of the upper left Outer Join and the right Outer Join (removing duplicates), that is, "Total outer = left outer Union right outer ".Note: The left table is the table on the left of the "(left Outer Join)" keyword. The right table is of course the right table. Among the three types of external connecti
the right table that do not meet the query conditions. The total outer join is actually a mathematical set of the upper left Outer Join and the right Outer Join (removing duplicates), that is, "Total outer = left outer union right outer ".Note: The left table is the table on the left of the "(left outer join)" keyword. The right table is of course the right table. Among the three types of external connecti
An interesting SQL queryA friend has such a SQL query requirement:There is a login table (Tmp_test) that contains the user ID (UID) and logon time (Login_time). The table structure is as follows:*************************** 1. Row***************************Field:uidtype:int(Ten) unsignedNull: NOKey: MULDefault:NULLExtra:*************************** 2. Row**********
When we use the traditional mysql_connect, mysql_query method to connect query database, if the filter is not strict, there is the risk of SQL injection, resulting in the site is attacked, out of control. Although you can use the mysql_real_escape_string () function to filter user-submitted values, there are also flaws. The SQL injection risk can be avoided by u
Srv_lnk. Database name. dbo. Table name--import ExampleSELECT * into table from Srv_lnk. Database name. dbo. Table name--Remove linked server when no longer in useexec sp_dropserver ' srv_lnk ', ' droplogins 'Go--The following example accesses data from a table that is in another instance of SQL Server.SELECT *from opendatasource (' SQLOLEDB ', ' Data source=servername; User Id=myuid; Password=mypass '). N
Essential SQL query optimization techniques to speed up Website access and SQL access
In this article, I will introduce how to identify queries that cause performance problems, how to locate their problems, and how to quickly fix these problems and other methods to speed up the query.
You must know that a website with
SQL statements remove duplicate records, get duplicate records
--Query a table to effectively remove duplicate records, UserID as a self-growing primary key, Roleid as a repeating field
The code is as follows
Copy Code
SELECT MIN (UserID) as UserID, Roleid from Tmptable GROUP by RoleidSELE
In database principles, clustering indexes are interpreted as follows: the order of clustering indexes is the physical storage order of data, while the non-clustering indexes are interpreted as follows: the index order is irrelevant to the physical data arrangement order. Because of this, a table can have at most one clustered index.
However, this definition is too abstract. In SQL Server, indexes are described through the binary tree data structure.
In database principles, clustering indexes are interpreted as follows: the order of clustering indexes is the physical storage order of data, while the non-clustering indexes are interpreted as follows: the index order is irrelevant to the physical data arrangement order. Because of this, a table can have at most one clustered index.
However, this definition is too abstract. In SQL Server, indexes are described through the binary tree data structure
query speed, the faster(Of course, don't look for an example with only a few hundred records to counter me.).
Let's go further: OK. Now let's take a look at it again. Let's change the SQL statement to see how MSSQL executes this SQL statement?Now remove the index: drop index t_userinfo.index_useridNow open [show stat
SQL query operation process and SQL operation processHere we can see the Query Processing of SQL in the book. In SQL, the query is achieved through the select statement and some auxilia
In programming languages with large numbers, the code is processed in the encoding order, but in SQL, the first clause to be processed is the FROM clause. Although the first SELECT statement appears, but it is almost always processed.Each step generates a virtual table, which is used as the input for the next step. These virtual tables are unavailable to callers (client applications or external queries. Only the table generated in the last step will b
performance problems. In terms of performance, each item shown below is not ideal.
Index or table scans (index or table scan): it may mean better or additional indexes are required.
Bookmark lookups: you can modify the current clustered index and overwrite the index to limit the number of fields in the SELECT statement.
Filter: Remove any function used in the WHERE clause. do not include a view in an SQL s
Top keyword: write in front of the field after selectFor example, you want to display the first 5 records of a query, as follows:Select Top 5 * from StudentIn general, top is the same as the order byOrder by uses the order by after the name of the table to fill in the fields you want to sort by, in ascending order (from small to large)Percent: Percent%=percentFor example, to display 5% of data processing, cannot write top 5%, but top 5 percentTip: If
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.