Currently, the projects at hand are made of LINQ, EF, and MVC, And I am confused by cainiao. Two days ago, I finally had some free time, and it took me some time to solve a long-standing question: When did EF submit a query to the database? Now let's share my little gains.
Why do I have the following questions:
Use the SQL database northwind and simple ASP. NET WebsiteProgramFor example, create a new de
classroom. SELECT distinct Tname,depart from score a joins Course B on A.cno=b.cno joins Teacher C on B.tno=c.tno where A.CNO In (B.CNO) --35, queries the tname and depart of all teachers who have not lectured. Select Tname,depart from Teacher where Tno not in (Selec T C.tno from score a joins Course B on A.cno=b.cno joins Teacher C on B.tno=c.tno where A.cno in (B.CNO)) --36 , check the class number of at least 2 men. Select class from student where ssex= ' Man ' GROUP by class has cou
V_cust_rcvlbesWHERE postcode> "98000"The number of rows in the view is less than the rows in the primary table, and the physical order is the required order, reducing disk I/O, so the query effort can be significantly reduced. 23, you can use distinct without GROUP bySELECT OrderID from Details WHERE UnitPrice > Ten GROUP by OrderIDCan be changed to:SELECT DISTINCT OrderID from Details WHERE UnitPrice > 10 24. Use UNION ALL to not use UnionUNION all
repeat the previous command.Sample SQL query on asql
The following is a few examples of SQL queries using asql for Apache log files:
Example 1: List the source/time and HTTP status code of the request in January 1, October 2014.
SELECT source, date, status FROM logs WHERE date> = '2017-10-01T00: 00: 00' order by sou
The SQL multi-table join query instance provides four SQL multi-table join query instances, with different efficiency.
The SQL multi-table join query instance provides four SQL multi-ta
tableSELECT COUNT (URL) from Wise_web_docinfo WHERE gathertime between ' 2016-05-30 00:00:00 ' and ' 2016-05-30 23:00:00 '9\\url Fuzzy QuerySELECT * from Sitemanage WHERE URLs like '%0634% '10\\ change other fields in the table based on the URL fieldUPDATE sitemanage SET category= ' Forum d ', updatestrategy=2 WHERE url like '%0634% '11\\in condition, limit condition querySELECT * from WebDB WHERE url in (select URL from curl) LIMIT 0,100012\\ Time QuerySelect?*? From?wise_web_docinfo? WHERE??
where num = 20
5. InAndNot inUse it with caution. Otherwise, full table scan may occur, for example:Select ID from t where num in (1, 2, 3)Continuous values can be usedBetweenDo not useInNow:Select ID from t where num between 1 and 3
6.The following query will also cause a full table scan:Select ID from t where name like '% ABC %'To improve efficiency, you can consider full-text search.
7. if you use parameters in the where clause, full ta
between 1 and 3
6. The following query will also cause a full table scan:
Select ID from t where name like '% ABC %'
To improve efficiency, you can consider full-text search.
7. If a parameter is used in the WHERE clause, a full table scan is performed. Because SQL parses local variables only at runtime, the optimizer cannot postpone the selection of the access plan to runtime; it must be selected at com
SQL query beginner's Guide Reading Notes (3) value expression introduction, beginner's Guide Reading Notes
CHAPTER 5 Getting More Than Simple Columns
Intro Value expression, itcontains column names, literal values, functions, orother value
Expressions
The type of data
TheSQL Standard defines seven general categories of types of data-character,
Nationalcharacter, binary, numeric, Boolean, datetime, and in
Common SQL Server date comparison and date query statements
In SQL Server, you may need to obtain the current date and calculate some other dates. For example, your program may need to determine the first or last day of a month. Most of you probably know how to divide a date (year, month, day, and so on ), then, just use the split year, month, and day to calculat
1. Convert time into a string:Copy codeThe Code is as follows:Convert (varchar, field name, 120) -------- yyyy-mm-ddhh: ss: mm0000Convert (char (10), field name, 120) ------ yyyy-mm-dd 2If you are using the SQL Editor (a tool provided by Microsoft), you do not need to use function conversion to query the date. For example:SQL codeCopy codeThe Code is as follows:Select * frominfowheredatatime> '
SQL query of date fields
// Query all the data generated at every daySelect * from table where datepart (HH, Date Field) = 8// Query all records whose dates are 2006-7-6Select *From cstrecordWhere (datepart ([Day], optime) = 6) and (datepart ([year], optime) = 2006) and(Datepart ([month], optime) = 7)1) Remove
Tags: else count ext obj Write hand string dbi work
SELECT TOP 30000Total_worker_time/ + as [Total CPU time consumed (ms)], Execution_count[Number of runs], Qs.total_worker_time/Qs.execution_count/ + as [average CPU time consumed (ms)], Last_execution_time as [Last Execution Time], Min_worker_time/ + as [Minimum Execution time (MS)], Max_worker_time/ + as [Maximum Execution time (MS)],
SUBSTRING(QT.text, Qs.statement_start_offset/2+1,
( Case whenQs.statement_end_off
A problem that has been resolved for a long time today,
The cause isObtain the data with the maximum time and date.
Previously, we thought that only the MSX function could solve the problem,
Select * From tablename where date = (select max (date) from tablename) and time = (select max (time) from tablename)
During the test, we found that a piece of data was taken out. Because the test was performed on two pieces of data in a day without a different date, we thought it was correct on that day
Query the connection information in the database. SQL _COMMAND is an SQL statement that can release A process: selectA. SID, B. SPID, a. SERIAL #, A. lockwait, A. USERNAME,.
Query the connection information in the database. SQL _COMMAND is an
Determine the installed SQL Server 2000 Database Components version
Use isql, osql, or query analyzer to Perform one of the following queries on Database Engine instances.
Select serverproperty ('productlevel ')
SELECT @ VERSION
Select serverproperty ('productversion ')
Use the following table to determine your Database Components version.
First, let's take a look at SQL server. Previously, we used the foreground to select a start time and an end time (in the smallest unit of day), and then used it as a condition for query, if we use "between starttime and endtime" as the condition, we will automatically convert "" to "00:00:00 ", therefore, the following query condition is "between '2014-06-16 'an
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.