Regex to get sql statement parts



Does anyone have a regex (or knows how to make one) that will get the
parts of an sql statement?

$sql = "SELECT (* or 'id, username, etc') FROM `(tablename)`, [WHERE
`id` = 1 and `username` = ".$username."][LIMIT (#)]"

it should return the following array:

$returnd_val = array(
'fields'=>''(* or 'id, username, etc')",
'table'=>"(tablename)",
'where'=>"(`id` = 1 and `username` = \"joe user\")",
'limit'=>"1"
);

A similar regex for update, delete, and insert would help too ;)

.