items. The following decision relationships exist in this database table:(Warehouse ID, store item id) → (Administrator id, quantity)(Admin ID, store item id) → (warehouse ID, quantity)So, (warehouse ID, store item ID) and (Administrator ID, store item ID) are the candidate keywords for storehousemanage, the only non-critical field in the table is the number, which is in accordance with the third paradigm. However, the following decision relationship exists:(warehouse id) → (Administrator id)(A
, and the index range scan is more suitable for finding >=,SELECT A.ItemID from Pt_sche_detail a,Pt_post_role bWHERE A.ItemID = b.taskid and A.docid = 2281 and A.ItemID! = 1169015 and a.status! = 0 and B.posttype = 1 and B.roleid = 1022 and B.roletype = 1The above statement is changed to:SELECTA.ItemID fromPt_sche_detail A,Pt_post_role bWHEREA.ItemID=B.taskid andA.docid=2281 andA.ItemID!=1169015 andA.status!=0 andB.taskidinch(SELECTItemid fromPt_sche_detail TempWHERETemp.docid=2281 andrownum (S
achievement of the same students with different course grades.43. Check the top two of the best results for each door44. The number of students enrolled in each course (more than 10 participants are counted). Require the output of the course number and the number of elective, query results in descending order of numbers, query results in descending order of numbers, if the number is the same, in ascending order by course number45. Retrieve the student number of at least two elective courses46.
)AsSELECT * from student where ID between @startId and @endIdGo--Call methodEXEC Proc_find_stu 2, 4; 2.3 Stored procedures with input and output parametersCreate proc Getcommentcount@newsid int,@count int OutputAsSelect @count =count (*) from Comment where [email protected]--Call methodDECLARE @newsid int,@count int;Set @newsid = 7;exec getcommentcount @newsid, @count output;Select @count;Print @count; 2.4 Functions that return a single valueCreate function MyFunction(@newsid int)returns intAsBe
; warehouse 1---n items. The following decision relationships exist in this database table:(Warehouse ID, store item id) → (Administrator id, quantity)(Admin ID, store item id) → (warehouse ID, quantity)So, (warehouse ID, store item ID) and (Administrator ID, store item ID) are the candidate keywords for storehousemanage, the only non-critical field in the table is the number, which is in accordance with the third paradigm. However, the following decision relationship exists:(warehouse id) → (Ad
Examples of scanning methods in SQL Server execution planOriginal address: http://www.cnblogs.com/zihunqingxin/p/3201155.html1. How to use the execution planSelect the statement you want to execute, click Ctrl+l to execute2. ExampleStudent table, id,name,addressBuild a clustered index on the IDName Build IndexAddress No Index3. Difference1. "table Scan": traverse the entire table to find all matching record
. Please note: This example and the other examples in this article will only use the DateDiff and DATEADD functions to calculate the date we want. Each example will get the date you want to calculate by calculating the previous time interval and then adding and reducing it. This is the SQL script that calculates the first day of the one month:
Select DATEADD (mm, DATEDIFF (Mm,0,getdate ()), 0)
Tags:--warning Color Recordset example Ali type store FASCursorA cursor is a data buffer opened by the system for the user, which holds the results of the SQL statement execution. Each cursor area has a name that allows the user to retrieve the record from the cursor one at a-and assign it to the main variable for further processing by the main language.Cursors are a mechanism for working with result sets, which can locate a row in the result set, rea
SQL Server COALESCE functions detailed
Many people know the IsNull function, but few people know the COALESCE function, people will inadvertently use the COALESCE function, and found that it is more powerful than isnull, in fact, so far, this function is indeed very useful, this article mainly explains some of the basic uses:
first look at the brief definition of Books Online:
Returns the first NON-EMPTY expression syntax in its arguments:
+a_salary.4. Write the UPDATE statement "update originsalary set o_salary=" To add the value "where o_id=" to get the value "5. Cycle 3 times to complete this function.Another way is to write a stored procedure, which I will not list here.I want you to think about this before learning about cursors, and some examples of batch processing. Some people might say, "Can't the database handle data in one row?" Addsalary the data of the table into rows, and
SQL storage is an important part of the database operation process, for some beginners is also more abstract difficult to understand, this article I will use several examples to resolve the SQL stored procedures in the database, so that the abstract things to visualize, easier to understand.
Example 1:
create proc Proc_stu
@sname varchar (),
@pwd varch
modern browsers, for data security, all requests are strictly restricted to the same domain name, and if you need to invoke data from different sites, you need to solve them across domains.The following PHP code runs using a Web site for cross-domain access.
Header ("Access-control-allow-origin: *");
More Cross-domain Access solutions refer to the best solution for PHP Ajax cross-domain problems.
1. PHP and MYSQL code examples
2. PHP
Label:A table is connected to itself, called a self-connectedQuestion: A netizen put forward such a SQL topic, said oneself thought for a long time did not solve, I see, this is not very simpleBut in the Query Analyzer debugging for half a day the original problem is not that simpleThere is a student's table, there is a study numberStudent score three fields. Use a SQL query to get the top two results for e
converted to columns, and in that specifies which specific rows to convert, and with these we cannot understand the following SQL: SELECT *From (Selectmonth, prd_type_id, amountFrom All_saleswhereYear = 2003 and prd_type_id in (1,2,3)) pivot ( sum (amount) for (month, prd_type_i d) in ((1, 1) as Jan_prd_type_1, (2, 2) as Feb_prd_type_2, (3, 3) as Mar _prd_type_3, (4, 2) as apr_prd_type_2); Using multiple aggregate functions in a transforma
This article describes the typical examples that sql*loader often use in the process of actual use.
1. How do I get fewer columns for the larger than data file in the table?
Suppose a CSV file is as follows:
A1,A2,A3,A4
b1,b2,b3,b4
c1,c2,c3,c4
d1,d2,d3,d4
A total of 4 columns, the first request as long as the 2nd, 3 columns of data, how to do? At this point, the filler (note: not the filter) para
.
Right join/right OUTER join: Outer joins the records from the two tables and contains all the records in the right-hand table. Simply put, and the left join in turn.
Full Join/full OUTER join: Complete outer joins return all rows in the left and right tables. is left join and right join and merge, and the data for both tables is displayed.
basic syntax for join:Select table1.* from table1 JOIN table2 on Table1.id=table2.id
SQL notation
INNER JOI
String function contents supported by SQL Server:
Copy Code code as follows:
LEN (String) function
LOWER (String) function
UPPER (String) function
LTRIM (String) function
RTRIM (String) function
SUBSTRING (string,start_position,length) function
CHARINDEX (string,substring) function
Left (string,length) function
Right (string,length) function
ASCII (String) function
ASCII (String) function
(1) LEN (string)
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.