umanda Posted June 2, 2010 Posted June 2, 2010 Sql Error Expand Post » hi friends I am developing a osCommerce website and I am strucking with displaying items. Ok Ill explain what my issue in my site ok I am using a sql query to display all the product in database. ok this is my query $products_new_query_raw = "select * from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' order by p.products_date_added DESC, pd.products_name"; no problem this query is perfectly working. but when I go the next level of menu it should be short under the category which was added to the particular menu item. ok for this case I was used a cat_id to select particular data regarding to the menu I create a another sql query, and it like this $products_new_query_raw = "select * from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and categories_id = '25'order by p.products_date_added DESC, pd.products_name"; I added few codes for WHERE clause. ( and categories_id = '25') but unfortunately it is given that following error massage 1054 - Unknown column 'categories_id' in 'where clause' select count as total from products p left join manufacturers m on (p.manufacturers_id = m.manufacturers_id), products_description pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and categories_id = '25' [TEP STOP] hmmm.....ok please help me... Thank you Umanda Jayo Bandara
Jan Zonjee Posted June 2, 2010 Posted June 2, 2010 1054 - Unknown column 'categories_id' in 'where clause' select count as total from products p left join manufacturers m on (p.manufacturers_id = m.manufacturers_id), products_description pd where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '1' and categories_id = '25' The categories_id is stored in the table product_to_categories. A product can be in more than one category! Be careful...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.