[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 60 days
Recommended Popular Threads Controvertial Threads
TRUMP 2016!!! Here is why?
~चौतारी १९९~
TPS to change of status denied ..Need help
TPS to GC (PERM-I140-I485) TimeLine
TPS EAD rejected: Help
नफर्किने गरि नेपाल जाने सोच
हामीहरुले २० जना केटिहरुसंग सेक्स गर्नै पर्छ रे नी !
Mnang, Mustang Treking and Our Engagement
Nepali people greencard in danger
रवि लामिछानेले येसोरी हत्या गर्यो शालिकराम पुडासैनीको ( with video )
filing H1b as gas station attendant
Osho Tapoban in Nepal
Stock ma lagani
2020 : Why No Trump !
Excellent Deal on Chase Sapphire Preferred Credit Card - Don;t miss out
Salary offer aako cha
US upcoming recession --- is it good time to buy house when rates are low or is it good time to wait recession?
अंग्रेजी नजानेर रातो पिरो भा छु
~चौतारी १९९~
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