[Show all top banners]

phone
Replies to this thread:

More by phone
What people are reading
Subscribers
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 Need help on Sql query
[VIEWED 6297 TIMES]
SAVE! for ease of future access.
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.


 
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.
 
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?
 
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

 
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.
.
 
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.
 
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');
 
Posted on 07-01-19 1:22 PM     [Snapshot: 333]     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

Thank you anarchy99.
 
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.
 
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
 
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 ?
 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 60 days
Recommended Popular Threads Controvertial Threads
TPS Re-registration case still pending ..
Toilet paper or water?
and it begins - on Day 1 Trump will begin operations to deport millions of undocumented immigrants
From Trump “I will revoke TPS, and deport them back to their country.”
Tourist Visa - Seeking Suggestions and Guidance
advanced parole
ढ्याउ गर्दा दसैँको खसी गनाउच
To Sajha admin
Nepali Psycho
MAGA denaturalization proposal!!
How to Retrieve a Copy of Domestic Violence Complaint???
wanna be ruled by stupid or an Idiot ?
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters