Don't Use Nested IFNULL, Use COALESCE - MySQL
If you're looking for how to do a nested IFNULL, you probably need to be looking at how to use COALESCE instead. It returns the first non-null item in a list.Example:
SELECT COALESCE(NULL,1);
Returns 1
IFNULL - MySQL
IFNULL(`field1`, `field2`)That returns field1 if it's not null. However, it will return field2 if it is null.
Notes On JOIN - MySQL
- If your INNER join is returning too few values and duplicates, you're probably using the wrong kind of join. Try a LEFT join.
- INNER JOIN is the same as JOIN
- http://i.stack.imgur.com/GbJ7N.png (diagram explaining joins)
- LEFT JOIN is used - this will return ALL rows from Table1, regardless of whether or not there is a matching row in Table2.
Indexes Help... A Lot
I just brought 4 queries from 15 seconds to less than 1 second by adding indexes to the columns in the ON() portion on the join.Indexes help... A lot.
Yii-Booster Incorrect Width
Set public $responsiveCss = false; to public $responsiveCss = true;group_concat - MySQL
http://mahmudahsan.wordpress.com/2008/08/27/mysql-the-group_concat-function/This seems like it will be super useful.
If you're using "group by" and you still want to get data out of the grouped rows, then you can use this to combine multiple rows into a single row.
Looping Through Associative Array - PHP
http://stackoverflow.com/questions/1951690/php-how-to-loop-through-a-associative-array-and-get-the-key-nameThis was totally not very intuitive. I was expecting something like this:
foreach($array as $sub) {
echo(key($sub));
}
Instead, it's this:
foreach ($decodedOutput as $key => $value) {
echo $key;
}