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!
Re: question about $sql statements
Quote:
Originally Posted by
tcarden
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.
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
Re: question about $sql statements
aye, yes!, a belated thank you.
i remembered after my posting that it is shorthand, thanks