[VIEWED 6299
TIMES]
|
SAVE! for ease of future access.
|
|
|
phone
Please log in to subscribe to phone's postings.
Posted on 06-30-19 2:36
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hello ,
I have a table called Member consisting of Columns MemberName, MotherName, and EmploymentStatus. I would like to create a query which gives me MemberName, MotherName, and EmploymentStatus in which the Mother's all Daughers are Emplpyee . In my table below I want row 1 as a result of the query.
|
|
|
|
ujl
Please log in to subscribe to ujl's postings.
Posted on 06-30-19 3:06
PM [Snapshot: 15]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
You need to create another table with mother daughter relationship. In real life, your table above will have actual names! It will be pretty confusing who is whose daughter without a separate table. Then, you can use foreign key to link that table with this table.
|
|
|
phone
Please log in to subscribe to phone's postings.
Posted on 06-30-19 3:56
PM [Snapshot: 46]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hi Ujl, Thank you for your reply. I already have a table in this format and it is not feasible to make another table quickly. Can someone suggest the query for the same table, please?
|
|
|
ujl
Please log in to subscribe to ujl's postings.
Posted on 06-30-19 4:17
PM [Snapshot: 54]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
SELECT * FROM Member WHERE MotherName = 'GrandMother1' AND EmployementStatus = 'Employee'; The above query will bring row 1 as a result.
Last edited: 30-Jun-19 04:18 PM
|
|
|
phone
Please log in to subscribe to phone's postings.
Posted on 06-30-19 4:30
PM [Snapshot: 68]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hi ujl, Thanks for your reply. In my table thousands of records where only some members of the same mother are employed. The query should be able to fetch the records of all mothers whose daughters are employed. .
|
|
|
ujl
Please log in to subscribe to ujl's postings.
Posted on 06-30-19 4:46
PM [Snapshot: 77]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
SELECT * FROM Member WHERE EmployementStatus = 'Employee'; This query will fetch all the rows where member are employed.
|
|
|
anarchy99
Please log in to subscribe to anarchy99's postings.
Posted on 06-30-19 10:50
PM [Snapshot: 183]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
not optimized... SELECT * FROM phonesTable pt1 WHERE pt1.EmployeeStatus = 'Employee' AND pt1.MemberName IN (select pt2.MotherName from phonesTable pt2 where pt2.EmployeeStatus = 'Employee') AND pt1.MemberName NOT IN (select pt3.MotherName from phonesTable pt3 where pt3.EmployeeStatus = 'Unemployee');
|
|
|
phone
Please log in to subscribe to phone's postings.
Posted on 07-01-19 1:22
PM [Snapshot: 333]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
|
|
|
phone
Please log in to subscribe to phone's postings.
Posted on 07-01-19 3:18
PM [Snapshot: 371]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Hello ananchy99, Can you share some tips to learn complicated SQL skripts/queries? Thank you.
|
|
|
maxpayne
Please log in to subscribe to maxpayne's postings.
Posted on 07-01-19 3:30
PM [Snapshot: 380]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
This --https://www.w3schools.com/sql/sql_exercises.asp
|
|
|
nepalichoro123
Please log in to subscribe to nepalichoro123's postings.
Posted on 07-01-19 3:52
PM [Snapshot: 396]
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
i am electrical engineer by profession. i think above type of queries i can do myself . will that make me capable of applying for entry level sql developer ?
|
|
|