come hai fatto dovrebbe andare bene.

Quando hai dei dubbi prova a stampare la stringa ottenuta.

echo $qry;