Guest Posted September 24, 2005 Posted September 24, 2005 Not being a PHP or SQL guru, I was wondering if someone could explain something to me - in laymans terms... Having played around with OSCommerce now for 2 years and minimally learning SQL and PHP I am wondering one thing. In many of the queries that the database uses, you come across things like pd., p., s., sometimes o. appended on to a field name...Why and how does this work. Considering the database is so picky that a goofy ";" can screw up an entire query....why doesn't appending these suffixes (for lack of a better word) to a field name mess up the query? For example I added Master Products to my admin/categories (and many other files - but this is the file I am dealing with right now) in combing two or more contributions, one inevitably must combine a query here and there...so far I've done okay in doing this...But I never understood the purpose for adding these suffixes. I added a p.products_master into a query that it is spitting back at me as if it doesn't recognize it. Now all the other fields in this query have "p." suffixes in them and I added the field products_master to the products table as the contribution required. So when I combined multi stores and master products I thought I would just add products_master into the query like all the other fields being called. Do I have to define the "p.products_master" somewhere else to get it to accept it. Could someone just give me a quicky lesson in how this part of the SQL world works in this area? or give me a link as to where I could find out what the heck I'm doing. Thanks for any input....or for that matter if anyone out there has combined these two contributions and would like to share their thoughts that would be great too...but I'd really like to understand this SQL thing for myself. Thanks Teresa
Flyer5 Posted September 24, 2005 Posted September 24, 2005 Not being a PHP or SQL guru, I was wondering if someone could explain something to me - in laymans terms...Having played around with OSCommerce now for 2 years and minimally learning SQL and PHP I am wondering one thing. In many of the queries that the database uses, you come across things like pd., p., s., sometimes o. appended on to a field name...Why and how does this work. Considering the database is so picky that a goofy ";" can screw up an entire query....why doesn't appending these suffixes (for lack of a better word) to a field name mess up the query? For example I added Master Products to my admin/categories (and many other files - but this is the file I am dealing with right now) in combing two or more contributions, one inevitably must combine a query here and there...so far I've done okay in doing this...But I never understood the purpose for adding these suffixes. I added a p.products_master into a query that it is spitting back at me as if it doesn't recognize it. Now all the other fields in this query have "p." suffixes in them and I added the field products_master to the products table as the contribution required. So when I combined multi stores and master products I thought I would just add products_master into the query like all the other fields being called. Do I have to define the "p.products_master" somewhere else to get it to accept it. Could someone just give me a quicky lesson in how this part of the SQL world works in this area? or give me a link as to where I could find out what the heck I'm doing. Thanks for any input....or for that matter if anyone out there has combined these two contributions and would like to share their thoughts that would be great too...but I'd really like to understand this SQL thing for myself. Thanks Teresa <{POST_SNAPBACK}> Hi You are referring to aliases. Heres an example, SELECT o.price,o.quantity,o.tax,c.name FROM orders o,customers c get it? we called our orders table o and our customers table c, if you write a huge select statement you can do without writing customers 20 times! Imagine you called your table customers_from_european_countries!! I have a useful e book somewhere that explains this, if you send me your e mail via pm ill mail it to you
Recommended Posts
Archived
This topic is now archived and is closed to further replies.