Posts Tagged Under MySQL

December 7th, 2008

Big MySQL dump import

Recently i faced problem “How to upload over 100 MB mysql dump into database”. Obviously it cannot be done using phpMyAdmin, because file is to big, i could open the file and execute query after query, but it would take a lot of time, besides opening such a file is a problem by itself. So i started to search for a solution and i found wonderful solution.

Posted in MySQL
By Greg
read more
October 23rd, 2008

MySQL Select NULL

How to select rows from MySQL table where certain field is empty is a problem i stuggled against for a while like … 10 minutes or so, while solution is quite simple. Remember that it will work with MySQL this solution was not tested with other databases and as far as i am concerned it does not work with Sybase.

SELECT * FROM `table` WHERE `field1` IS NULL

There is also variations for this:

SELECT * FROM `table` WHERE ISNULL(`field1`)

While browsing MySQL documentation i found one more interesting function IFNULL(expr1, expr2). What it basically do is: if expr1 is NULL then it returns expr2 else it returns expr1. Here is a sample usage:

mysql> SELECT IFNULL(1,0);
-> 1
mysql> SELECT IFNULL(NULL,10);
-> 10
mysql> SELECT IFNULL(1/0,10);
-> 10
mysql> SELECT IFNULL(1/0,'yes');
-> 'yes'

That’s it for now, i hope you will find it helpful.

Posted in MySQL
By Greg
read more
September 5th, 2008

Shorthand for MySQL JOIN

Hey guys, i am currently finishing my degree at collage and do not have a lot of time to write as you can see. Last month was short on post and i believe that this month will also be short, although i have already long list of topics i want to write about. Anyway i managed to find some time so here something interesting i found recently.

Posted in MySQL
By Greg
read more