Archive for the ‘mysql’ Category

count(1) vs count(*) - any difference?

Friday, January 19th, 2007

A while ago when I started my first job in LA, I was using MSSQL. I was told to never use count(*), and rather to use count(1). Several people insisted this performs better than count(*), and since I really didn't care to argue or look into it, I ...

Why have REPLACE INTO and INSERT … ON DUPLICATE KEY UPDATE?

Wednesday, January 17th, 2007

REPLACE INTO will actually perform a delete and then an insert, while INSERT ... ON DUPLCIATE KEY UPDATE will perform an update (as the name suggests). I would think the latter would be faster. I have not done any performance testing between the two, but it only seems ...

Paging Through Data 2.0

Saturday, November 11th, 2006

For a long time, whenever I wanted to do paging to browse through a table, I used to run 2 queries. The first would get the results, and the second would be an almost identical query, with a count() instead of fields, and I'd use the result of the ...

Can you use a stored procedure in a subquery? I don’t think so. (MySQL)

Wednesday, September 27th, 2006

I do not think you can use the result of a stored procedure in an ad-hoc subquery. On my social network, LetsGetNuts.com, I have a Friend table. This is the structure: mysql> describe Friend; +----------------+---------------+------+-----+---------+-------+ | Field | Type ...

MySQL: Number + NULL = NULL

Wednesday, September 20th, 2006

Maybe not breaking news, but I think it's interesting enough of a point, and I didn't really find anything about the topic when I googled it. If you do any addition, subtraction, multiplication, or division (and probably a lot more mathematical functions for that matter) and NULL is one of ...

MySQL Triggers Tutorial

Thursday, September 14th, 2006

If you've worked with any of the commerical databases other than MySQL, you may have already had some experience with triggers. I'm glad that the MySQL developers finally managed to squeeze in this extremely important feature. I no longer dread trying to defend MySQL from the Microsoft and Oracle developers ...