how u did the query.where statement?, cuz the q.where statement works like
query.where = "NOMBRE='MADRID'";
And also the layer url has to have the parameter that u are asking for.
Telefonica,
Being able to see some of your code like where you define your query object and define what your outfields are etc would help.
Robert