suppose we have values like 1 5 7 in a colum.Now we want
numbers like(2 3 4 6) that exists between 1 5 7.How can we
do this using sql query??

Answer Posted / elumalai d

--QUESTION36:-What is different between union and minus?

UNOIN:- it returns all the records from both tables without duplicates.
Example:-
A={1,2,3,4}
B={2,3,4,5,6}
AUB={1,2,3,4,5,6}

CREATE TABLE question36 (empid NUMBER);
CREATE TABLE quest36 (empid NUMBER);

INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);

INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(4);
INSERT INTO quest36 VALUES(5);
INSERT INTO quest36 VALUES(6);
COMMIT;

SELECT empid FROM question36
UNION
SELECT empid FROM quest36;

DELETE FROM question36;
DELETE FROM quest36;
COMMIT;

MINUS:- it returns table A values not available in table B.
Example:-
A={1,2,3,4}
B= {2,3,5}
A-B={1,4}

INSERT INTO question36 VALUES(1);
INSERT INTO question36 VALUES(2);
INSERT INTO question36 VALUES(3);
INSERT INTO question36 VALUES(4);

INSERT INTO quest36 VALUES(2);
INSERT INTO quest36 VALUES(3);
INSERT INTO quest36 VALUES(5);
COMMIT;

SELECT empid FROM question36
MINUS
SELECT empid FROM quest36;

DROP TABLE question36;
DROP TABLE quest36;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to analyze tables with 'mysqlcheck'? : Sql dba

547


What makes a good primary key?

524


What is cte sql?

517


Is postgresql a server?

577


How do you get column names only for a table (sql server)?

669






How do I find duplicates in a single column in sql?

536


How do I count records in sql?

518


What is $$ in sql?

553


when is the use of update_statistics command? : Sql dba

504


What are the types of views in sql?

542


What is the usage of distinct keyword?

632


How do I kill a query in postgresql?

554


how to create a table index in mysql? : Sql dba

597


How can we implement rollback or commit statement in a trigger?

580


What is a stored procedure in sql with example?

606