Home > database >  The content of the update query of oracle,
The content of the update query of oracle,

Time:09-16




Two tables have ZKZMBH, LSH, SFZMHM, CARNO, are the same, but let's not careful the first table CARNO emptied, now want to do a query update statement,
CARNO T table of query out on E table CARNO,,
Note: T table inside the same admission ticket number can 20 or so,,,,
E table inside the same admission ticket number one or two,,
Ask everybody to help write a SQL, write their own always suggest the subquery return multiple values,,,

Thank you

CodePudding user response:

Make sure the same ZKZMBH T table, LSH, only one SFZMHM CARNO,
The SELECT ZKZMBH, LSH, SFZMHM, CARNO FROM T GROUP BY ZKZMBH, LSH, SFZMHM HAVING COUNT (DISTINCT CARNO) & gt; 1;

After the execution
UPDATE E SET e.c. with our fabrication: ARNO=(SELECT DISTINCT CARNO T the WHERE the FROM T.Z KZMBH=E.Z KZMBH AND T.L SH=E.L SH AND T.S FZMHM=E.S FZMHM) WHERE (ZKZMBH, LSH, SFZMHM) IN (SELECT ZKZMBH, LSH, SFZMHM FROM T);

CodePudding user response:

Search the oracle link updated

CodePudding user response:

grade watch is E, carno is car number, ZKZMBH is admission ticket number, LSH is serial number , KSCS is the number fields, students, if the examination is only a record, the number is 1, two times to have two, the number is 2, the other fields of information are the same, and then don't accidentally update E set carno=null,

So according to the inside of the process information table T students corresponding carno he query insert into,, but E table is because have a plenty of a two uncertain write the subquery prompt return multiple values,
T, and E table ZKZMBH, LSH, T table a admission ticket number of real-time data about 20 ~ 30, but ZKZMBH, LSH, CARNO fields are the same, T table has KSCS the number field,,

SELECT ZKZMBH, LSH, CARNO FROM HIS_LK_UPLOADRECT t WHERE to_char (SJ, '- dd yyyy - mm)=' 2018-04-19 'GROUP BY ZKZMBH, LSH, CARNO , can query to each person's admission ticket, the corresponding car number, but how to write the table E ZKZMBH, there may be two ZMZMBH, there may be a like this,

Thank you, big brother @! @

CodePudding user response:

reference 1st floor billywang777 response:
make sure the same ZKZMBH T table, LSH, only one SFZMHM CARNO,
The SELECT ZKZMBH, LSH, SFZMHM, CARNO FROM T GROUP BY ZKZMBH, LSH, SFZMHM HAVING COUNT (DISTINCT CARNO) & gt; 1;

After the execution
UPDATE E SET e.c. with our fabrication: ARNO=(SELECT DISTINCT CARNO T the WHERE the FROM T.Z KZMBH=E.Z KZMBH AND T.L SH=E.L SH AND T.S FZMHM=E.S FZMHM) WHERE (ZKZMBH, LSH, SFZMHM) IN (SELECT ZKZMBH, LSH, SFZMHM FROM T);


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Grades watch is E, carno is car number, ZKZMBH is admission ticket number, LSH is the serial number, KSCS are the number field, students, if the examination is only a record, the number is 1, test has two twice, the number is 2, the other fields of information are the same, and then don't accidentally update E set carno=null,

So according to the inside of the process information table T students corresponding carno he query insert into,, but E table is because have a plenty of a two uncertain write the subquery prompt return multiple values,
Process watch is T, and E table ZKZMBH, LSH, T watch a admission ticket number of real-time data about 20 ~ 30, but ZKZMBH, LSH, CARNO fields are the same, also have a number of KSCS test field, T tables,

SELECT ZKZMBH, LSH, CARNO FROM HIS_LK_UPLOADRECT t WHERE to_char (SJ, '- dd yyyy - mm)=' 2018-04-19 'GROUP BY ZKZMBH, LSH, CARNO, can query to each person's admission ticket, the corresponding car number, but how to write the table E CARNO, there may be two ZKZMBH, there may be a like this,

Thank you, big brother @! @