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 7713 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 90 days
Recommended Popular Threads Controvertial Threads
Conservative discussions
सालीको चाक
Venezuela TPS lawuit
Homeland Security revokes temporary status for 532,000 Cubans, Haitians, Nicaraguans and Venezuelans
Best Consultancy for H1 sponsorship in USA.
Nepal TPS decision
What is the purpose of an F1 student visa in the U.S.?
#MAGA#FAFO is delicious
महँगो अण्डाको पिकल्प : कुखुरा र खोर भाडामा लिने
Homeowner Charged renting to illegal migrants
Measles vax deaths vs measles death in USA
Why some Nepali people pull each other's legs???
Please ask KRISTI NOEM in her facebook and other social media to renew TPS
US citizen Petitioning my wife who was out of status when she was in H1B. What to do ?
Travelling to Nepal with expiration less than 6 months
ICE kidnapping people off the streets over op eds
Don’t Just Read—Join the Conversation
FDA admits Covid mRNA ‘Vaccines’ CAUSE CANCER
MLS AND LIVE SOCCER MATCH FREE SITE THAHA CHA?
रबि लामिछानेको दाहिने हात ICE को हिरासतमा
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