[Show all top banners]

Replies to this thread:

More by phone
What people are reading
:: Subscribe
Back to: Kurakani General Discussion Refresh page to view new replies
 Need help on Sql query
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       ?        

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       ?        

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.



Within last 365 days
Recommended Popular Threads Controvertial Threads
TRUMP 2016!!! Here is why?
Returning to Nepal
महानियिका प्रियंका कार्कीजीलाइ खुल्ला पत्र !
भाउजु आउनु भाकी छिन रे नि !
~चौतारी १९९~
chat girl -आजो सुक्रबार-२
Looking for Potential Match
हाकिमनी संग- आज सुक्रबार -३
What stocks to buy -- Any recommendation
पिन्कुको नया काले हस्पि नाक चुचेय भाते भतुवा
Mnang, Mustang Treking and Our Engagement
Indian Worker Attitude
Learning computer programming
Wedding Costs in Nepal ? Party, Band Baaja !!!!???
प्रियंका कार्की फोटो अबलम भाग २ , ३ जून २०१६ copyright @पुन्टर
प्रियंका .का. लै चिठी भाग १
Looking for a man
अनभिज्ञ तिमी
वाह ! मन्त्री ज्यु वाह !
हाम्रो #Quarantine समयको सदुपयोग
Don't apply Canada Immigration through COLIN R. SINGER
Funny jokes
Presidential rights to assassination rights?
Former U.S. President Bill Clinton in Nepal
Build the Wall-MAGA
~चौतारी १९९~
महानियिका प्रियंका कार्कीजीलाइ खुल्ला पत्र !
TRUMP 2016!!! Here is why?
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