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
Explain about a primary key?
Pgm A calls Pgm B and pgm B uses cursor, when pgm B is called second time, the program is abending saying the cursor is opened? Why?
Explain about post-relational databases?
What are the constraints on severity level in raiseerror?
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
State the acid rules?
What you can do to remove data from the cache and query plans from memory for testing the performance of a query repeatedly?
Explain about the relational database?
How to use timestamp datatypes
Explain about relational operator join?
How to read and create .LDC data files which are used by linguatic dictionary.
What are the three types of database design?
How can you log an error to the server event log from a stored procedure?
1. Using the XML Document below, with the URI “recipe.xml”
define
the following queries in XQuery:
a.) Give the names of all breakfast in the menu.
b.) Select breakfasts that have price lower than $7.00?
Why does this query return 0?