Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Why SQL query have p, pd etc on Zen Cart but table in SQL no the p or pd?

    Hi all,

    I am new on php/MySQL and now want to learning it to take more control of Zen Cart.

    I have one questions not understand.

    It is on MySQL table, such as products, inside it haven't the "p", for example products_id, products_model etc.

    But general on the php coding, will see like that query

    $products_query_raw = "select p.products_id, p.products_model, pd.products_name, p.products_quantity, p.products_type from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id='" . $_SESSION['languages_id'] . "' order by ".$sOrder." ";
    $products = $db->Execute($products_query_raw);


    Why add the addition p or pd. on the table's column name on the query? What do it doing?

    Thank you very much. And anyone can give me a tutorial good for beginner like me?

  2. #2
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: Why SQL query have p, pd etc on Zen Cart but table in SQL no the p or pd?

    It's called an alias and is a short way of talking to mysql about the table without having to type the whole table name each time.

    Otherwise we would have to say things like products.products_id = products_description.products_id when using more than one table in a query to tell mysql to which we are referring, which would get a bit tedious.

    There's a tutorial on it here.
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  3. #3
    Join Date
    Jan 2007
    Posts
    375
    Plugin Contributions
    3

    Default Re: Why SQL query have p, pd etc on Zen Cart but table in SQL no the p or pd?

    Kurio,

    Thank you very much, now understand where the p, po come from by SQL Alias.

 

 

Similar Threads

  1. v139h Save the Multi Table Query Result in phpmyadmin or by SQL CLI
    By explorer1979 in forum General Questions
    Replies: 2
    Last Post: 31 Dec 2013, 09:03 PM
  2. v151 SQL query setup. How do I TEST a query 'off-line'?
    By lewisasding in forum General Questions
    Replies: 3
    Last Post: 8 Mar 2013, 12:24 AM
  3. Replies: 3
    Last Post: 17 Oct 2012, 02:13 AM
  4. Replies: 1
    Last Post: 25 May 2012, 04:23 AM
  5. Needing sql query to drop table prefix
    By audradh in forum General Questions
    Replies: 5
    Last Post: 11 May 2011, 12:51 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