mysql-5.1

mysql 5.1 signal an error to cause PDO exceptions

我是研究僧i 提交于 2020-01-07 03:39:13
问题 I know mysql 5.5 allows using SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Error: ...'; to raise a user defined error. And this error will stop an INSERT operation if it was put in the BEFORE INSERT TRIGGER on some tables. And it's also convenient for PDO to catch the PDOException and output the errorinfo() i.e. MESSAGE_TEXT defined in SIGNAL SQLSTATE . However, the version of mysql on the server I rent is mysql 5.1. And I want to know how can I raise a user defined error with the features

Extremely Slow Select Query on MySQL

谁都会走 提交于 2019-12-22 04:36:38
问题 I’m trying to understand why a select query runs extremely fast on my laptop while extremely slow on the server. The query takes 1.388 seconds to run on the laptop while 49.670 seconds on the server. Both schemas are identical as I have exported the scheme from the laptop and imported it into the server. Both are running MySQL 5.1.36 on WAMP 2.0. SQL Dump https://db.tt/4TvuOWbD Query SELECT form.id AS 'Form ID', DATE_FORMAT(form.created_on, '%d %b %Y') AS 'Created On - Date', DATE_FORMAT(form

How can I cast an int to a bit in MySQL 5.1?

感情迁移 提交于 2019-12-17 13:53:33
问题 I am transitioning from SQL Server to MySQL 5.1 and seem to be tripped up trying to create a table using a select statement so that the column is a bit. Ideally the following would work: CREATE TABLE myNewTable AS SELECT cast(myIntThatIsZeroOrOne as bit) AS myBit FROM myOldtable However sql is very unhappy at casting as a bit. How can I tell it to select an int column (which I know only has 0s and 1s) as a bit? 回答1: You cannot! CAST and CONVERT only work to: BINARY[(N)] CHAR[(N)] DATE

Extremely Slow Select Query on MySQL

前提是你 提交于 2019-12-13 06:51:37
问题 I’m trying to understand why a select query runs extremely fast on my laptop while extremely slow on the server. The query takes 1.388 seconds to run on the laptop while 49.670 seconds on the server. Both schemas are identical as I have exported the scheme from the laptop and imported it into the server. Both are running MySQL 5.1.36 on WAMP 2.0. SQL Dump https://db.tt/4TvuOWbD Query SELECT form.id AS 'Form ID', DATE_FORMAT(form.created_on, '%d %b %Y') AS 'Created On - Date', DATE_FORMAT(form

How to use INSERT … SELECT with a particular column auto-incrementing, starting at 1?

我是研究僧i 提交于 2019-12-13 05:33:35
问题 I am using INSERT ... SELECT to insert a data from specific columns from specific rows from a view into a table. Here's the target table: CREATE TABLE IF NOT EXISTS `queue` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `customerId` int(11) NOT NULL, `productId` int(11) NOT NULL, `priority` int(11) NOT NULL, PRIMARY KEY (`ID`), KEY `customerId` (`customerId`), KEY `productId` (`productId`), KEY `priority` (`priority`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; The INSERT ... SELECT SQL I have works, but

Undefined method 'accept' for nil:NilClass after upgrading to Rails 3

随声附和 提交于 2019-12-10 17:28:16
问题 I just upgraded my Rails application from Rails 2.3.8 to Rails 3.2.7 and I've run across a problem with Activerecord. If I try to access my database with Activerecord at all(Ex: Employee.last), I get the following error: NoMethodError: undefined method `accept' for nil:NilClass from /home/aneyer/.rvm/gems/ruby-1.8.7-p370@rails3/gems/activerecord-3.2.7/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql' from /home/aneyer/.rvm/gems/ruby-1.8.7-p370@rails3/gems

Which row (in order by some column) in a table corresponds to a row in another table?

这一生的挚爱 提交于 2019-12-08 07:39:13
问题 I have two tables, as follows (simplified from actual): mysql> desc small_table; +-----------------+---------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------------+---------------+------+-----+---------+-------+ | event_time | datetime | NO | | NULL | | | user_id | char(15) | NO | | NULL | | | other_data | int(11) | NO | MUL | NULL | | +-----------------+---------------+------+-----+---------+-------+ 3 rows in set (0.00 sec) mysql> desc

Extremely Slow Select Query on MySQL

别等时光非礼了梦想. 提交于 2019-12-05 03:34:34
I’m trying to understand why a select query runs extremely fast on my laptop while extremely slow on the server. The query takes 1.388 seconds to run on the laptop while 49.670 seconds on the server. Both schemas are identical as I have exported the scheme from the laptop and imported it into the server. Both are running MySQL 5.1.36 on WAMP 2.0. SQL Dump https://db.tt/4TvuOWbD Query SELECT form.id AS 'Form ID', DATE_FORMAT(form.created_on, '%d %b %Y') AS 'Created On - Date', DATE_FORMAT(form.created_on, '%h:%i %p') AS 'Created On - Time', department.name AS 'Department', section.name AS

Is it possible to do sql injection with stored procedures?

余生颓废 提交于 2019-12-04 06:22:32
问题 I saw some similar question, none about mysql... Is there any way to do a sql injection into a SP? How do I protect from this on the SP level? In other words, can the Query strucutre, inside a SP can be modified in any way by an incoming parameter? If I send to a stored procedure the parameter "1;DELETE FROM users;--" and the query is: select * from T where = @p 回答1: SQL injection is, basically, adding extra code to the query. The attack itself occurs because the server parses the input data