Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2012
    Posts
    282
    Plugin Contributions
    0

    Default question about $sql statements

    via a client's request, i'm adding a 'features list' to the products table.

    right now i just have question about the Query found in 'main_template_vars.php'

    the query is this:
    select count(*) as total from zen_products p, zen_products_description pd .....etc.

    what does the 'p' and the 'pd' mean following the table names??, unfamiliar w/ such a syntax.

    thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: question about $sql statements

    Quote Originally Posted by tcarden View Post
    the query is this:
    select count(*) as total from zen_products p, zen_products_description pd .....etc.

    what does the 'p' and the 'pd' mean following the table names??, unfamiliar w/ such a syntax.

    thanks!
    The construct zen_products p, zen_products_description pd defines a 'shorthand notation' that will be used in the query. Further in the query, you might find some variables referenced as p.products_id and pd.products_id which refer to the products_id field in the products table and the same field in the products_description table, respectively.

  3. #3
    Join Date
    Jan 2004
    Posts
    66,364
    Blog Entries
    7
    Plugin Contributions
    274

    Default Re: question about $sql statements

    lat9 is correct.
    Those are table "alias"es.
    p.products_id (when p is defined by zen_products in your example) is much easier to write and read than zen_products.products_id
    especially when you get into writing WHERE and JOIN clauses such as
    WHERE zen_products.products_id=zen_products_description.products_id AND zen_products_description.language_id = 1 .... etc
    vs just
    WHERE p.products_id=pd.products_id and pd.language_id=1 ... etc
    .

    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
    Oct 2012
    Posts
    282
    Plugin Contributions
    0

    Default Re: question about $sql statements

    aye, yes!, a belated thank you.

    i remembered after my posting that it is shorthand, thanks

 

 

Similar Threads

  1. Question about using SQL
    By tcarden in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 15 Jan 2013, 04:32 PM
  2. How did you hear about us (SQL question)
    By Serious in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 10 Oct 2011, 02:31 PM
  3. SQL statements
    By jasonsmith991 in forum General Questions
    Replies: 3
    Last Post: 30 Sep 2010, 09:32 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