Discover sql query to compare two columns in same table, include the articles, news, trends, analysis and practical advice about sql query to compare two columns in same table on alibabacloud.com
No matter what database I use, duplicate data exists. Next I will introduce in detail various methods and Performance Analysis for deleting duplicate records in Oracle tables, for more information, see.
Method:
The Code is as follows:
Copy code
Group by XX having count (*)> 1, rowid, distinct, temporary table, procedure
The following statement can query the data that is duplic
/*Normal row and column conversionsLet's say a student score table (TB) is as follows:Name Subject ResultZhang San language 74Zhang San Mathematics 83Zhang San Physics 93John Doe Language 74John Doe Mathematics 84John Doe Physics 94*/-------------------------------------------------------------------------/*Want to becomeName Chinese mathematics Physics---------- ----------- ----------- -----------Lee 474 84 94Sheet 374 83 93*/CreateTable TB(Name varc
Tags: assign ble. com ROM Presence nbsp query condition ASEMaster these, it's more advanced. Using the same Table twice such as the Branch field in the following query SELECTa.account_id, e.emp_id, B_a.name open_branch, B_e.name emp_branch fromAccount asAINNER JOINBranch asB_a ona.open_branch_id=b_a.branch_idINNER JOINEmployee asE ona.open_emp_id=e.emp_idINNER JO
There are three of tablesDiscuss_tableTalk_tableUser_tableYou can then query all the contents of three tables or query some of the contents. The following statement is tested, take it out and share it!SELECT * FROM (select Row_number () over (order by d_id Desc) as rownum,a.*,b.*,c.* from (discuss_table as a inner join TALK_TA ble as B on a.titleid=b.t_id) join User_table as C on a.user_id=c.u_id where c.us
Three sheets
Title Table topic, field to_id to_title
Knowledge Point table tag, field t_id T_title
Association table relation, field to_id t_id
Each topic can have multiple knowledge points
Now the Web interface provides search box, 10 small questions per page, users can choose more knowledge points, encountered the problem is that there is duplicate
--Cross join produces a Cartesian value (x*y) SELECT * from Student crosses Join dbo. ClassInfo--Another way of writing select * from Student, ClassInfo--INNER join (Inner can omit) select *from Student JOIN dbo. ClassInfo on dbo. Student.class = dbo. classinfo.id;--Inner Join SELECT *from Student Inner join dbo. ClassInfo on dbo. Student.class = dbo. Classinfo.id; --on condition, usually the primary foreign key, but not limited to the primary foreign key--on condition, which allows multiple, a
1 Public functionGet_search ($page=1){2 $slide=$_post[' Slide '];3 $page=Trim($page);4 $arr=$this->m->get_all ("Select a.* from ' Lx_z_news ' as a where a. ' title ' like '% ').$slide." % ' UNION ALL SELECT b.* from ' lx_z_product ' as B where B. ' title ' Like '% '.$slide." %‘ ");5 $row=Count($arr);6 $page 2=page ($page,$row, 10);7 $select _from=$page 2[' Select_from '];8 $select _limit=$page 2[' Select_limit '];9 $arr 1=$this->m->get_all ("Select ' A ' tbname,a.title,a
Label: string text = "SELECT * from [admin] where aa=1 and cc= ' B ' ORDER by AA Desc";Regex reg = null; reg = new Regex (@ "\s+from\s+.*?" ( \s+where\s+|\s+order\s+|\s+group\s+) |\s+from\s+.+ ", regexoptions.ignorecase);string table = Reg. Match (text).
Value; Table = Regex.Replace (table. ToLower (), @ "\s+from\s+|\s+where\s+|\[|\]|\s+order\s+|\s+group\
See a friend write another SQL statement: Two tables A1 table has SN, SN2, TN,B1 table has SM, SM2, TN2, if the data in the SN of A1 and B1 of the data in the SM is consistent, then the corresponding data in A1 is modified to the corresponding data in B1.Update a1 Set SN2 = (select B1. SM2 from B1 where A1. SN = B1. SM), TN = (select B1. TN2 from B1 where A1. SN
Label:Many people may want to query the entire tree table associated content will be returned through the loop to check ... In fact, Microsoft can query with other syntax in SQL2005 or later, here is an example. --Querying parent nodes through child nodesWithTREE as (SELECT * FROM areasWHERE id = 6--The child ID to queryUNION AllSELECT areas.* from areas, TREETh
Table 1: Table 2:Id info id value1 a 1 102 B 2 303 c4 dWant to getId value1 10 // Table 2 exists2 20 // Table 2 exists3 0 // Table 2 does not exist4 0 // Table 2 does not existWhether an SQL
Table 1: Table 2:
ID Info id value
1 A 1 10
2 B 2 30
3 C
4 d
Want to getID value1 10 // Table 2 exists2 20 // Table 2 exists3 0 // Table 2 does not exist4 0 // Table 2 does not existWhether an
Tags: style blog color io os using SP div on UseMYDB1Go--Table T_employee2--Id Name Position Dept--1 Three Employees marketing Department--2 John Doe Manager Sales Department--3 Harry Manager Marketing Department--4 MA Six Employee Sales Department--5 Money seven employee marketing departmentSelect * fromT_employee2--Requirements: Query all employees in the table
Select*From(SelectP. object_owner,P. SQL _id,S. runtime_mem,S. buffer_gets,S. sorts,S. disk_reads,S. parse_cils,S. sharable_mem,S. Executions,Round (S. disk_reads/decode (S. Executions, 0, 1, S. executions), 0) as disk_reads_per_exec,Round (S. buffer_gets/decode (S. Executions, 0, 1, S. executions), 0) as buf_gets_per_exec,Round (S. parse_cils/decode (S. Executions, S. executions), 1) as parse_calls_per_exec,S. SQ
One: If the target table to insert does not exist:Select * into from where ...Two: If you want to insert the target table already exists:Insert into Select * from where conditionThree: If it is a cross-database operation: How to put the atable table of a database, all the things that are queried into the btable table
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.