// id don't know the exact syntax, but this is what you are searching for I guess:
// replace spaces with nothin temporarily, then check equal (=) not like (%%) if name is exactly the same (except the spaces)
SELECT id, REPLACE(name, ' ', '') AS tmp FROM table WHERE tmp='%$name%'