What is a self join? Explain it with an example?

Answer Posted / krishna prasad a

For this Answer 1 is incorrect.

CREATE TABLE candytest
(kidId char(2),
candycolor varchar(10)
)
GO

INSERT INTO candytest SELECT 'K1', 'Yellow'
INSERT INTO candytest SELECT 'K1', 'Red'
INSERT INTO candytest SELECT 'K2', 'Red'
INSERT INTO candytest SELECT 'K2', 'Blue'
INSERT INTO candytest SELECT 'K3', 'White'
INSERT INTO candytest SELECT 'K3', 'Red'
INSERT INTO candytest SELECT 'K3', 'Yellow'
Go
--Now to find those kidid's which has both yellow and red
colored candies, we can write query as:

Select c1.candytest from
candytest c1,candytest c2
where c1.candycolor=c2.candycolor
and c1.kidid=c2.kidid

Is This Answer Correct ?    20 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Who are naive users?

611


I HAVE A PI ON COL A THE NEXT DAY I WANT CHANGE THE PI ON COL B? PLS SEND ME THE ANS

2423


How to use timestamp datatypes

1583


How is data stored in dbms?

528


If a column is an image value type, how you can compare column values? How can you use this column in join clause?

598






Explain about normal forms?

604


How you can make a parameterized view?

561


What is the physical representation for a many-to-many relationship?

580


Hi , any one can help me on the same,this is regarding the Informatica Function doc,i want to know how developer is will develop the mapping. pl forwar the any function doc .just for my references. svlc75@yahoo.co.in

1593


I have a few records all are same structures data, I want to store data in multiple targets how

2147


Explain what a database is?

615


Explain about the database management systems.

572


Explain about network model?

591


What is database design and development?

609


Hi my program is accesing data from two db2 databases.what is the bind card for this program to genarate plan? how to specify the two owners and two qualifiers in bind card

1679