--1 and enquiries about employees who entered the company in 1981SELECT *From EMPwhere hiredate between ' January-January-1981 'and ' 3 January-December-1981 ';SELECT *From EMPwhere HireDate >= ' January-January-1981 'and HireDate --2, query Manager
Select a from a a b where a.t=b.tSelect a from a-a where a.t in (select b.t from b b)Select distinct a.org_code,a.org_name from t_organzation a,t_dm_cdbp_organzation b where a.org_code=b.org_code;Select distinct a.org_code,a.org_name from
(1): Query whether a table exists in a database ( two ways): Assuming that the table name is table_nameif exists (select * from sysobjects where name= ' table_name ')DROP TABLE table_nameIf OBJECT_ID (' table_name ') is NOT nullDROP TABLE
Find records for all repeating headings:SELECT *From T_info AWHERE (SELECT COUNT (*)From T_infoWHERE Title = a.title) > 1)ORDER by Title DESCOne. Find Duplicate Records1. Find all duplicate recordsSELECT * FROM table Where repeating field in (Select
1) SQL Where conditionSelect Id= "Find" parametertype= "user" resulttype= "user" >select Id,name, age,address from User_c where 1=1and id=#{id}and name like "%" #{name} "%" and age=#{age}and address=#{address}2) ... will automatically remove the and
In an Oracle database, you can merge fields using the wm_concat (column) functionThe Oracle Wm_concat (column) function allows us to use it frequently, and below teaches you how to use the Oracle Wm_concat (column) function to implement a field
Study site: http://www.w3cschool.cc/sql/sql-tutorial.html
One: Querying the properties of all tablesSELECT 'ALTER TABLE'+ Case wheno.schema_id is not NULL Then(SELECTNAME+'.' fromSys.schemasWHEREschema_id=O.SCHEMA_ID)ELSE "' END
SQL Query day, week, month record--Day of enquiry:[SQL] View plaincopyprint?SELECT * FROM info where DateDiff (dd,datetime,getdate ()) =0--Query within 24 hours:[SQL] View plaincopyprint?SELECT * FROM info where DateDiff (hh,datetime,getdate ())
CREATE TABLE Marklist(Name varchar (10),Course varchar (10),Mark float)Insert into Marklist (Name,course,mark) VALUES (' Zhang San ', ' math ', 75);Insert into Marklist (Name,course,mark) VALUES (' John Doe ', ' language ', 76);Insert into Marklist (
Select(SELECT COUNT (*) from DEVICE0 where status! = 0),(SELECT COUNT (*) from Device1 where status! = 0),(SELECT COUNT (*) from Device2 where status! = 0),(SELECT COUNT (*) from device3 where status! = 0),(SELECT COUNT (*) from Device4 where status!
1. To optimize the query, avoid full-table scanning as far as possible, and first consider establishing an index on the columns involved in the Where and order by.2. Avoid null-valued fields in the WHERE clause, which will cause the engine to
Simple description: Today look at the boss to submit the code, found an interesting thing, a SQL judge condition is empty, eldest brother's writing, let me before the light. Directly on the codeCode: Select from where r.xxx_level = ' 0 '
drop table #Area; CREATE TABLE #Area (ID INT not NULL, City_name NVARCHAR (+) NOT NULL, parent_id INT NOT null) INSERT into #Area ( ID,CITY_NAME,PARENT_ID) VALUES (1, ' Jiangsu Province ', 0) insert into #Area (id,city_name,parent_id) VALUES (2, '
Decode functionOracle is unique and powerful. Equivalent if else ifIF Condition = value 1 ThenRETURN (translation value 1)elsif condition = value 2 ThenRETURN (translation value 2)...elsif condition = value N ThenRETURN (translated value
Original: SQL query statement group BY, string mergeMerge column Values--*******************************************************************************************table structure with the following data: ID value----- ------1AA1BB2AAA2BBB2CCC needs
Insert operation:
1. Copy the table structure without adding data:
--Copy table structure without inserting data create TABLE Emp_new as SELECT * from emp where 1 = 2;select * from emp_new;
2. With CHECK option, the Mate view can
Used to hibernate, and then replaced by MyBatis will encounter some abnormal problems, as the following error prompt, with the MyBatis query, pass in a string argument, and when judged, the error is reportedThere is no getter for property named '
The essential reason is that SQL Server statistics contains only the information for the first column of the composite index, not the composite index data combinationFrom a practical problem in the work,This is where the combination column data is
Records reprinted from: Http://www.cnblogs.com/suruozhong/p/5974595.htmlall data for today: SELECT * FROM table name where DateDiff (dd,datetime Type field, GETDATE ()) =0 all data for yesterday: SELECT * from table name where DateDiff (DD, DateTime
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.