If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Pervasive.SQL > SQL statement i can't figure out

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-03, 08:51
TPnTX TPnTX is offline
Registered User
 
Join Date: Mar 2003
Posts: 5
SQL statement i can't figure out

If anyone can easily do this I'd appreciate it. I'm scratching my head and burning time.

I have 4 tables all using Uinique ID's as primary key

Profile,PofileDetail, Vendorparts & Vendor.

I want to list all detail records that have a vendorpart where name like '%NLA' and display vendor name

Profile.UID
Profile.Number

ProfileDetail.UID
ProfileDetail.ProfileNumber
ProfileDetail.VenPartID

VendorParts.UID
VendorParts.PartName

Vendor.UID
Vendor.Name

Profile.Number VendorPart.PartName Vendor.Name
-----------------------------------------------------------------

I've come close to doing it but when I add the vendor.Name to the mix, all the vendor.PartName fields display the same PartName.
Thanks

Last edited by TPnTX; 04-01-03 at 08:54.
Reply With Quote
  #2 (permalink)  
Old 04-01-03, 09:00
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,540
i'm not sure how your tables are related
Code:
select ProfileDetail.ProfileNumber
     , VendorParts.PartName
     , Vendor.Name
  from ProfileDetail
inner
  join VendorParts
    on ProfileDetail.VenPartID = VendorParts.UID
inner
  join Vendor
    on ??????????
rudy
http://r937.com/
Reply With Quote
  #3 (permalink)  
Old 04-01-03, 09:18
TPnTX TPnTX is offline
Registered User
 
Join Date: Mar 2003
Posts: 5
relates

select ProfileDetail.ProfileNumber
, VendorParts.PartName
, Vendor.Name
from ProfileDetail
inner
join VendorParts
on ProfileDetail.VenPartID = VendorParts.UID
inner
join Vendor
on ??????????


You thats exactly what I've done except I didn't use the Inner/join/on
It's works fine doing the vendorpart join.

Oh I left one field out in the example. The VendorPart.VendorID field points to Vendor.UID. Thats where I have trouble trying to join it similar to the Detail-to-VendorPart join.

I'm trying you example now adding:
Inner
Join
on Vendor.UID = VendorParts.VendorID
Reply With Quote
  #4 (permalink)  
Old 04-01-03, 09:30
TPnTX TPnTX is offline
Registered User
 
Join Date: Mar 2003
Posts: 5
Done

That did it!

I see to things that gave me trouble.

1 I wasn't using the join/inner/on. Actually I tried.

2
on ProfileDetail.VenPartID = VendorParts.UID

I would have thought the this to be
VendorParts.UID = ProfileDetail.VenPartID


Thanks though it works now.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On