INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Need help with a self join problem - PervasiveSQL

Need help with a self join problem - PervasiveSQL

(OP)
Hello I am trying create a series of views to show details of staff and their linemanagers,yet can not get them to work. Details of Staff records are in 2 files (Staff1,Staff2), They are linked via fieldname 'PersonKey' and Staff2 contains a field 'PersonKeyMainline' which is the personkey for the linemanager. I am trying to pull out details for both the Staff member and the line manager.

this is my attempt...

SELECT
Staff1.FirstName,
Staff1.Surname,
Staff2.PersonKey,
Staff2.Address1,
Staff2.Address2,
Staff2.Address3,
Staff2.Postcode,
Staff2.PersonKeyMainline

From Staff2 Child2,staff1 Child,Staff1 Parent,Staff2 Parent2
Where  Child.PersonKey = Child2.PersonKey AND Child2.PersonKeyMainline = Parent2.PersonKeyMainline and Parent.PersonKeyMainline = Parent.Personkey

I cannot get this to work. I have only just started to learn SQL so have probably made some fundamental errors.

Thankyou in advance.

David Ison

RE: Need help with a self join problem - PervasiveSQL

What's the behavior are you seeing?  
Also, what version of PSQL are you using?

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Need help with a self join problem - PervasiveSQL

(OP)
Thanks for the speedy response.

I am Using pervasive SQL version 9.50.077.002.
When trying to execute the script I get
"[LNA][Pervasive][ODBC Engine Interface]Error in expression: Staff1 . FirstName "

RE: Need help with a self join problem - PervasiveSQL

I think it's because you don't have a reference to Staff1 other than to alias it.  You might try:
SELECT
Parent.FirstName,
Parent.Surname,
Parent2.PersonKey,
Parent2.Address1,
Parent2.Address2,
Parent2.Address3,
Parent2.Postcode,
Parent2.PersonKeyMainline

From Staff2 Child2,staff1 Child,Staff1 Parent,Staff2 Parent2
Where  Child.PersonKey = Child2.PersonKey AND Child2.PersonKeyMainline = Parent2.PersonKeyMainline and Parent.PersonKeyMainline = Parent.Personkey

Mirtheil
Certified Pervasive Developer
Certified Pervasive Technician
http://www.mirtheil.com

RE: Need help with a self join problem - PervasiveSQL

(OP)
That's it.
Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close