Queries like this can get tricky depending on your table design.
If your table looks like this:
<pre>CREATE TABLE MyTable
(ParentId INT,
ParentSequence INT, /*A number which is unique per parent*/
Value INT)</pre>
You can do something like this
<pre>SELECT *
FROM ParentTable
WHERE EXISTS (SELECT * FROM MyTable WHERE MyTable.ParentId = ParentTable.ParentId AND ParentSequence = 1)
AND EXISTS (SELECT * FROM MyTable WHERE MyTable.ParentId = ParentTable.ParentId AND ParentSequence = 2)</pre>
If you want to return the records that simply have 2 or more records in the MyTable table then something like this would work.
<pre>SELECT *
FROM ParentTable
JOIN (SELECT ParentId, count(*) ct
FROM MyTable
GROUP BY ParentId
HAVING count(*) >= 2) a ON a.ParentId = ParentTable.ParentId</pre>
well ur question is not clear, if u r a beginner,u might trouble to get the details from a table,
to retrive all columns and rows information
type the query "select * from parent;",
if u need to get the particular column or row information u need the condition to retrive the data as "select age from parent where age>40;" this is the code to retrive
Last Wiki Answer Submitted: September 2, 2011 4:18 am by Denny Cherry64,520 pts.
All Answer Wiki Contributors: Denny Cherry64,520 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
well ur question is not clear, if u r a beginner,u might trouble to get the details from a table,
to retrive all columns and rows information
type the query “select * from parent;”,
if u need to get the particular column or row information u need the condition to retrive the data as “select age from parent where age>40;” this is the code to retrive
well ur question is not clear, if u r a beginner,u might trouble to get the details from a table,
to retrive all columns and rows information
type the query “select * from parent;”,
if u need to get the particular column or row information u need the condition to retrive the data as “select age from parent where age>40;” this is the code to retrive