views:

132

answers:

6

What are the must-know MYSQL functions (like IF etc..,) which every web developer should know?

+5  A: 

My favorite:

INSERT ... SELECT

It allows me to bypass heavy PHP code to fetch data from one table, manipulate it and insert into another.

shamittomar
+2  A: 

My personal favorite is "insert... on duplicate key update..." ;-)

Every string functions: concat, concat_ws, ... now().

GROUP BY functions: sum(), max(), count() + the wonderful group_concat()

JOIN clauses and VIEWs if you you are planning complex requests.

Well, in fact, the more you know MySQL (I mean, everything), the best.

Capsule
+4  A: 

i'd say:

CREATE VIEW .. AS SELECT

when i have querys that i use all the time, but it's not a function =P

pleasedontbelong
This greatly removes dependence on complex ORMs.
stillstanding
@stillstanding - agree wholeheartedly
f00
+4  A: 

Triggers and stored procedures offer much automation that involve only the SQL engine and this will significantly reduce the Web server's load and PHP code involved in data housekeeping.

stillstanding
+1  A: 

My favorite:

alter table child add Foreign key (parent_id) references parent(id);

Taking care of data integrity with foreign keys will reduce your code base a lot. Not mentionign MySQL is better at this than PHP.

Richard Knop
+1  A: 

Some features that come to my mind:

danilo