Rails migrations: creating a MySQL BIGINT
7/04/2010add_column :facebook_user_id, :integer, :limit => 8 # BIGINT
small snippets of webmonkey wisdom
add_column :facebook_user_id, :integer, :limit => 8 # BIGINT
First make sure you have the MySQL client libraries installed, then:
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
Source: http://weblog.rubyonrails.com/2007/10/26/today-is-leopard-day
The SQL parser in PHPMyAdmin 2.6.x (the version used in Plesk 7.5) falls over when confronted with an ISNULL query, for example:
SELECT ISNULL(id) FROM user
The bug is fixed in recent versions of PMA (2.9.x works fine).
Warning: Incompatible change: As of MySQL 4.1.2, handling of the FLOAT and DOUBLE floating-point data types is more strict to follow standard SQL. For example, a data type of FLOAT(3,1) stores a maximum value of 99.9. Before 4.1.2, the server allowed larger numbers to be stored. That is, it stored a value such as 100.0 as 100.0. As of 4.1.2, the server clips 100.0 to the maximum allowable value of 99.9. If you have tables that were created before MySQL 4.1.2 and that contain floating-point data not strictly legal for the data type, you should alter the data types of those columns
from http://dev.mysql.com/doc/refman/4.1/en/upgrading-from-4-0.html
It isn’t possible to refer to a column alias in a WHERE clause, but you can use HAVING instead.
From http://dev.mysql.com/doc/refman/5.0/en/problems-with-alias.html:
This restriction is imposed because when the WHERE code is executed, the column value may not yet be determined. For example, the following query is illegal:
SELECT id, COUNT(*) AS cnt FROM tbl_name WHERE cnt > 0 GROUP BY id;The WHERE statement is executed to determine which rows should be included in the GROUP BY part, whereas HAVING is used to decide which rows from the result set should be used.
My example using HAVING:
SELECT ms.id, ms.name, COUNT( mpc.page_id ) AS count FROM map_supplier ms LEFT JOIN map_profile_content mpc ON ms.id = mpc.map_supplier_id GROUP BY ms.id HAVING count > 0
Use MySQL’s REGEXP support.
SELECT * FROM blah WHERE COLUMN REGEXP '^[0-9]+';