Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Simple INNER JOIN not returning results

    So i have product type forklift, when adding a new product, adds a ton of extra fields to a table using products_id = forklift_id,
    I did it a few years ago and its working great, now they are adding a new forklift notification system, (its own little nightmare in another post),
    I am setting up listeners that when a new forklift is added, if someone signed up for notifications fitting the specs of the forklift.

    I am also setting up a manual notification system and on page load, i want to see which forklifts have been added.
    PHP Code:
    $sel_forklifts "select pf.forklift_id, pf.forklift_cpac, pf.forklift_fuel, pf.forklift_tires, pf.forklift_make, pd.products_id from "
            
    .TABLE_FORKLIFT" pf" .
            
    " INNER JOIN " .TABLE_PRODUCTS" pd".
            
    " ON pf.forklift_id = pd.products_id ".        
            
    " where pd.products_date_added between '".$tdate."' and '".$edit_time."'"
    Even pasting into the mysql backend:
    SELECT pf.forklift_id, pf.forklift_cpac, pf.forklift_fuel, pf.forklift_tires, pf.forklift_make, pd.products_id
    FROM zen_forklift pf
    INNER JOIN zen_products pd ON pf.forklift_id = pd.products_id
    WHERE pd.products_date_added
    BETWEEN '2016-07-04'
    AND '2016-07-14'
    LIMIT 0 , 30

    No results

    Seems to not return any hits, even though i know there are at least 6 that should come up.
    Can anyone give me a little guidance, im not the best with joins.
    Thanks a ton.
    Jeff

  2. #2
    Join Date
    Jul 2012
    Posts
    16,799
    Plugin Contributions
    17

    Default Re: Simple INNER JOIN not returning results

    Thinking that because the dates are actual date fields, that need to address them similar to the following:

    Code:
    SELECT pf.forklift_id, pf.forklift_cpac, pf.forklift_fuel, pf.forklift_tires, pf.forklift_make, pd.products_id
    FROM zen_forklift pf
    INNER JOIN zen_products pd ON pf.forklift_id = pd.products_id
    WHERE pd.products_date_added
    BETWEEN CAST('2016-07-04' AS DATE)
    AND CAST('2016-07-14' AS DATE)
    LIMIT 0 , 30;
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jan 2004
    Posts
    66,419
    Blog Entries
    7
    Plugin Contributions
    277

    Default Re: Simple INNER JOIN not returning results

    Ya, I'd test by removing the "where" clause first. If that returns results then you'll know it's date-related.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,799
    Plugin Contributions
    17

    Default Re: Simple INNER JOIN not returning results

    Quote Originally Posted by DrByte View Post
    Ya, I'd test by removing the "where" clause first. If that returns results then you'll know it's date-related.
    Thinking a little further on it (and to help with the above test), might want to (temporarily) add the pd.products_date_added field on the return set just so it shows in you results so you can confirm your "suspicion" of having those at least 6 product.


    .
    Last edited by DrByte; 15 Jul 2016 at 06:09 PM. Reason: (added "temporarily")
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Jun 2009
    Posts
    86
    Plugin Contributions
    0

    Default Re: Simple INNER JOIN not returning results

    Quote Originally Posted by mc12345678 View Post
    Thinking that because the dates are actual date fields, that need to address them similar to the following:

    Code:
    SELECT pf.forklift_id, pf.forklift_cpac, pf.forklift_fuel, pf.forklift_tires, pf.forklift_make, pd.products_id
    FROM zen_forklift pf
    INNER JOIN zen_products pd ON pf.forklift_id = pd.products_id
    WHERE pd.products_date_added
    BETWEEN CAST('2016-07-04' AS DATE)
    AND CAST('2016-07-14' AS DATE)
    LIMIT 0 , 30;
    Worked perfectly, thank you!

  6. #6
    Join Date
    Jul 2012
    Posts
    16,799
    Plugin Contributions
    17

    Default Re: Simple INNER JOIN not returning results

    Quote Originally Posted by jeffiec View Post
    Worked perfectly, thank you!
    Quite welcome! :) good luck!
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v153 Is a simple way to redirect the inner page links?
    By su35 in forum General Questions
    Replies: 0
    Last Post: 10 Dec 2014, 08:23 PM
  2. Search/Advanced Search not returning results
    By scottfr in forum Setting Up Categories, Products, Attributes
    Replies: 11
    Last Post: 6 Apr 2011, 06:08 AM
  3. Search and Advanced search not returning results
    By paisore in forum General Questions
    Replies: 6
    Last Post: 4 Nov 2010, 03:43 PM
  4. developer toolkit not returning results - language pack problem?
    By whitenoises in forum General Questions
    Replies: 2
    Last Post: 9 Feb 2009, 11:24 PM
  5. Replies: 1
    Last Post: 29 May 2008, 10:54 PM

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
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR