I have just upgraded Magento from 1.5.1.0 to 1.9.2.1 and I am stuck at this error when I try to view a product:
a:5:{i:0;s:1427:"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'rule.calculate_subtotal' in 'field list', query was: SELECT `main_table`.`tax_calculation_rate_id`, `main_table`.`tax_calculation_rule_id`, `main_table`.`customer_tax_class_id`, `main_table`.`product_tax_class_id`, `rule`.`priority`, `rule`.`position`, `rule`.`calculate_subtotal`, `rate`.`rate` AS `value`, `rate`.`tax_country_id`, `rate`.`tax_region_id`, `rate`.`tax_postcode`, `rate`.`tax_calculation_rate_id`, `rate`.`code`, IF(title_table.value IS NULL, rate.code, title_table.value) AS `title` FROM `tax_calculation` AS `main_table` INNER JOIN `tax_calculation_rule` AS `rule` ON `rule`.`tax_calculation_rule_id` = main_table.tax_calculation_rule_id INNER JOIN `tax_calculation_rate` AS `rate` ON rate.tax_calculation_rate_id = main_table.tax_calculation_rate_id LEFT JOIN `tax_calculation_rate_title` AS `title_table` ON rate.tax_calculation_rate_id = title_table.tax_calculation_rate_id AND title_table.store_id = '1' WHERE (customer_tax_class_id = 3) AND (product_tax_class_id IN ('2')) AND (rate.tax_country_id = 'GB') AND (rate.tax_region_id IN(0, 0)) AND (rate.zip_is_range IS NULL) AND (rate.tax_postcode IS NULL OR rate.tax_postcode IN('*', '', 'ig9 5bw', 'ig9 5bw*', 'ig9 5b*', 'ig9 5*', 'ig9 *', 'ig9*', 'ig*', 'i*')) ORDER BY `priority` ASC, `tax_calculation_rule_id` ASC, `tax_country_id` DESC, `tax_region_id` DESC, `tax_postcode` DESC, `value` DESC";i:1;s:6703:"#0 /home/wwwarabesquecost/public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
I have tried to manually add it using this link : https://sarfarazlaghari.wordpress.com/2015/06/06/magento-sqlstate42s22-column-not-found-1054-unknown-column-rule-calculate_subtotal-in-field-list/ but this doesn't make a difference.
Has anybody had this issue before?
Regarding
I have tried to manually add it using this link : https://sarfarazlaghari.wordpress.com/2015/06/06/magento-sqlstate42s22-column-not-found-1054-unknown-column-rule-calculate_subtotal-in-field-list/ but this doesn't make a difference
Are you saying you've added the column to the tax_calculation_rule table but you're still getting the above error? If that's the case then you've updated the wrong database table, or a configuration file in app/etc is pointed at a different database from the one you think it is.
If that's not what you're saying then be clearer in your question.
The query that you found at that link has an obvious error: it create a new field in the table with the same name of the table.
The right query, which solve the error, is the following:
ALTER TABLE tax_calculation_rule
ADD calculate_subtotal TINYINT(1) NOT NULL DEFAULT 0
Hope it helps.
You shouldn't run sql alternations just like that. The OP mentioned this has happened after an upgrade to 1.9x.
Having such errors means that your codebase is upgraded but your database is still outdated.
The best way for this would be to alter the core_resource table for the module (e.g. tax_setup) to the version that his database was aware previously, and let magento handle the database updates.
Related
I upgraded to Phoca Download on my J3.1.5, now I´m getting the problems when I wanted to download the file:
1054 - Unknown column 'c.tokenhits' in 'field list'
SELECT c.catid, c.filename, c.directlink, c.link_external, c.access, c.confirm_license, c.metakey, c.metadesc, cc.access as cataccess, cc.accessuserid as cataccessuserid, c.tokenhits FROM yav95_phocadownload AS c, yav95_phocadownload_categories AS cc WHERE c.id = 33 AND c.published = 1 AND c.approved = 1 AND c.catid = cc.id AND cc.access IN (1,1,5) AND ( c.publish_up = '0000-00-00 00:00:00' OR c.publish_up <= '2013-10-13 13:35:28' ) AND ( c.publish_down = '0000-00-00 00:00:00' OR c.publish_down >= '2013-10-13 13:35:28' ) ORDER BY c.ordering LIMIT 0, 1
since Phoca Download version 3.0.2, there are new table columns in database tables. When you upgrade from 3.0.1 to 3.0.2, Joomla! extension manager correctly reads the update instructions and update your database.
But when you upgrade from 3.0.1 to 3.0.3 or similar, it can happen, that the tables will be not upgraded. You will see e.g. the above mentioned error.
In such case, Phoca Download file table needs to be updated manually. Run your phpMyAdmin application and add the following SQL queries in your database.
See the guide which described it step by step:
http://www.phoca.cz/documents/16-joomla/759-how-to-solve-problems-which-occur-while-upgrading-joomla-extensions
I need to update two columns in a table in mysql. I have written following code in ZF2 model
$sql = new Sql($dbAdapter);
$update = $sql->update();
$update->table($table_name)
->set(array('checksum' => '', 'mailed_status' => 0))
->where('id = ' . $record_id);
$statement = $sql->prepareStatementForSqlObject($update);
$statement->execute();
Here in the above code, checksum is varchar column and mailed_status is bit column. The above query only updates checksum field but the mailed_status remains same (previously 1)
When I was updating mailed_status as 1, it works. I mean it updates 0 to 1 but the vice versa is not working.
I have printed the query and found that it makes quote around digit like this: '0' and '1'.
But I am wondering here. '1' is working but '0' is not, why?
What is the proper solution for this? Temporarily I changed the bit data type to varchar(1) in mysql database's table.
Thanks
Thats because 0 is treated like a Null value when updating your database. Changing column type to varchar(1) it's simpler than override sql update method!
Hi. I've been confused by this the last two days.
I am using Flynax for my Smarty project, but inside I can't update the admin app->common->configuration
I am getting this error:
MYSQL ERROR
Error: Unknown column 'Array' in 'having clause'
Query: SELECT `IP` AS `Count` FROM `fl_login_attempts` WHERE `IP` = '123.236.230.132' AND `Status` = 'fail' AND `Interface` = 'admin' GROUP BY `Date` HAVING TIMESTAMPDIFF(HOUR, `Date`, NOW()) < Array
Function: error
Class: rlDb
File: /home/autotrad/public_html/includes/classes/rlDb.class.php (line# 116)
Does anyone know how to solve it - is anyone getting the same error?
Yea Sundar disabling "register_globals" will solve the problem for sure!
With the help of this community, I was able to produce a query using an inner join which I thought would work for what I'm trying to do. Unfortunately, when I attempted to run the query found below, I received the following error:
ERROR: table name "bue" specified more than once
From what I've read on Google, some people have said that the "FROM bue" is not needed, but when I removed this, I got another error found below:
ERROR: syntax error at or near "INNER" at character 98
I'd very much appreciate your assistance in troubleshooting this. Thank you so very much.
Query:
UPDATE
bue
SET
rgn_no = chapterassociation.rgn_no,
chp_cd = chapterassociation.chp_cd
FROM
bue
INNER JOIN
chapterassociation
ON bue.work_state = chapterassociation.work_state
AND bue.bgu_cd = chapterassociation.bgu_cd
WHERE
bue.mbr_no IS NULL AND bue.chp_cd IS NULL
In PostgreSQL, specifying the table to be updated needs to be done only in the UPDATE clause, e.g. UPDATE bue. The FROM clause is only for additional tables referenced in the query. (If you were doing a self-join on bue, you would mention it again in the FROM clause, but you aren't in this case.)
The second error you get is likely just a simple syntax error. The other tricky thing is that JOIN/ON syntax doesn't fit in the FROM clause, so you have to move the join conditions to the WHERE clause. Try something like:
UPDATE
bue
SET
rgn_no = chapterassociation.rgn_no,
chp_cd = chapterassociation.chp_cd
FROM
chapterassociation
WHERE
bue.mbr_no IS NULL AND bue.chp_cd IS NULL
AND bue.work_state = chapterassociation.work_state
AND bue.bgu_cd = chapterassociation.bgu_cd
See http://www.postgresql.org/docs/current/interactive/sql-update.html.
(N.B. At least I don't know how to put JOIN/ON into an UPDATE statement... I could be missing something.)
So I have an import/export module for OpenCart, but it's wiping the entire product option table before inserting new data...
I need to develop support for the 3rd party product options module I have, but in the meantime--I figure I'd just stop it from deleting an important column in my product options table.
In the product_option_value table, I have 'product_option,' 'product_id,' 'quantity' etc., and there's one column named 'info' that I want to NOT wipe. The method is below:
function storeOptionsIntoDatabase( &$database, &$options )
{
// find the default language id
$languageId = $this->getDefaultLanguageId($database);
// start transaction, remove options
$sql = "START TRANSACTION;\n";
$sql .= "DELETE FROM `".DB_PREFIX."product_option`;\n";
$sql .= "DELETE FROM `".DB_PREFIX."product_option_description` WHERE language_id=$languageId;\n";
$sql .= "DELETE FROM `".DB_PREFIX."product_option_value`;\n";
$sql .= "DELETE FROM `".DB_PREFIX."product_option_value_description` WHERE language_id=$languageId;\n";
$this->import( $database, $sql );
...more code...
}
I'm not that familiar with MySQL, but I want something to the effect of:
$sql .= "DELETE FROM `".DB_PREFIX."product_option_value` WHERE column != 'info';\n";
Thanks!
Edit:
I tried Michael's suggestion to use UPDATE and explicitly setting them all to NULL... but that returned this error:
Error: Duplicate entry '0' for key 1
Error No: 1062 UPDATE
oc_product_option_value SET
product_option_value_id=NULL,
product_option_id=NULL,
product_id=NULL, quantity=NULL,
subtract=NULL, price=NULL,
prefix=NULL, sort_order=NULL,
weight=NULL, sku=NULL, image=NULL
I tried taking out the primary key:
$sql .= "UPDATE
".DB_PREFIX."product_option_value
SET product_option_id=NULL,
product_id=NULL, quantity=NULL,
subtract=NULL, price=NULL,
prefix=NULL, sort_order=NULL,
weight=NULL;\n";
but I get:
Error: Duplicate entry '1' for key 1
Error No: 1062 INSERT INTO
`oc_product....
Edit:
Okay, so I removed the 'primary_key' field from the INSERT... and I got no error messages from the upload. But when I view a product that product options, I get this message the top of my page:
Notice: Undefined index: name in
/httpdocs/ocart/catalog/model/catalog/product.php
on line 418Notice: Undefined index:
name in
/httpdocs/ocart/catalog/model/catalog/product.php
on line 418Notic.... it repeats
Make sure I understand: You want to clear values from all columns in the table product_option_value except for the column info ? If that's what you want, then the following may work. Please don't run it before we're clear on what you're trying to do!
DELETE FROM syntax implies deleting from a table name, not a column name. What you'll need to do instead is to UPDATE your rows to set all columns except the one you intend to keep to be either NULL or empty or their default value.
Don't forget to add a WHERE condition if you need to keep some rows as they are without modifying them! Without a WHERE, this query will NULL out all columns specified in the whole table.
UPDATE product_option_value
SET
product_option = NULL,
product_id = NULL,
quantity = NULL,
etc...
WHERE (some where condition if you need one)
I'm adding a second answer, taking a completely different approach which avoids SQL problems.
Export your table as a comma-separated text file. You can do this with phpmyadmin, or MySQL Workbench.
Open your CSV in a spreadsheet
Clear out the columns you want to clear out.
Save as a new CSV
Import the CSV back into your database using phpmyadmin, Workbench, or the LOAD DATA LOCAL INFILE syntax.