why would you write SQL with JavaScript? don't think that JavaScript yet at a point it can run heavy GUI element, handle AJAX, maybe Video or 3D and Query a database. JavaScript likes JSON very much, so all you need is just export your data with a language like PHP in JSON format, and handle it with JavaScript.