DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2007
    Posts
    4

    SELECT query help

    Hi everyone,

    I am trying to pull a value from a field in a program database and display it on my custom form. I am not sure if its my syntax or what, but it keeps crashing with the SELECT query i am using. I want to grab the G/Liability expiration date from the vndcrt table. Here is the query I have most recently tried.

    [SELECT vndcrt.expdte FROM vndcrt
    WHERE vndcrt.recnum = subcon.vndnum AND vndcrt.dscrpt = 'G/LIABILITY']

    here is an attachment showing the tables and data I am trying to retrieve.

    www.indesignmedia.com/tables.jpg

    Thanks for any help.

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You're referencing the subcon table in the WHERE clause, but it's not listed in the FROM clause. Also, you're not passing a specific recnum value. Try something like this:

    SELECT vndcrt.expdte
    FROM vndcrt
    WHERE vndcrt.recnum = 616
    AND vndcrt.dscrpt = 'G/LIABILITY'
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Dec 2007
    Posts
    4
    I have to reference the subcon table because every subcontract that is printed will usually reference a different subcon.vndnum other than 616, depending on the job. So i am trying to tell it to match the subcon.vndnum (vendor #) with the vndcrt.recnum (record #) and also match where the description reads G/LIABILITY.

    so if the vendor number 616 in this case matches the vendor certification record number of 616 then we have a match, and to pull the expiration date from the G/LIABILITY.

    make sense. thx

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Are you trying to print the records for ALL subcontractors where the description is G/LIABILITY, or only those records for a specific subcontractor or job? If it's the latter, you must somehow provide the ID of the subcontractor or job you're looking for.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Dec 2007
    Posts
    4
    yea, I want to do the later, for a specific job. The vendor id is the same as the record number in the vndcrt table. Is there any way to have it match the 2 and if its a match for the vendor i want to print, it will pull the value for that vendor?

    I posted this in another forum, so the info may or may not help. these are screens from the actual program master builder i am trying to make the query for. i am printing these reports from the subcontracts screen of 6-7-1

    www.indesignmedia.com/masterbuilder.jpg

  6. #6
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    if its a match for the vendor i want to print...
    That's the key: How does the query know which vendor you want to print? If you want to pass in the record number you're viewing in the subcontractors table, you can do this:

    SELECT vndcrt.expdte
    FROM vndcrt INNER JOIN subcon ON vndcrt.recnum = subcon.vndnum
    WHERE subcon.recnum = [record #]
    AND vndcrt.dscrpt = 'G/LIABILITY'
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  7. #7
    Join Date
    Dec 2007
    Posts
    4
    the program knows which vendor to print because on the screen I use to print the subcontracts, it has what vendor I am using displayed under vendor name.
    If you look on the masterbuilder.jpg picture, the top box of 6-7-1 has the vendor displayed there. So whichever subcontract I am printing, it shows what vendor its for.

    I also tried your last query and it seemed to crunch numbers longer before it crashed the program, which is better than what I was getting before.

Similar Threads

  1. Replies: 5
    Last Post: 08-18-2006, 01:15 PM
  2. Multi-table Select Query using Joins
    By knightsg in forum Database
    Replies: 0
    Last Post: 02-16-2005, 08:07 AM
  3. reg...select count distinct....query
    By Mohan Ekambaram in forum Database
    Replies: 0
    Last Post: 12-09-2001, 11:56 AM
  4. Get 10 months forward with select statment
    By Nirit Touboul in forum Database
    Replies: 7
    Last Post: 02-25-2001, 11:34 AM
  5. Stored Procedure (Want looping in Cursor)
    By malikmehmood in forum Database
    Replies: 0
    Last Post: 11-20-2000, 05:12 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links