If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Converting SQL script to JavaScript

Hi, so I will be undergoing a programming test tomorrow for a project interview in my company.

Beyond doing a basic training in JavaScript, the content of which should be similar to the JS Basics in w3schools, I havent really worked purely in this langauage. Instead I have done a fair bit of ExtJS, java and a bit of jQuery too.

My interviewers are aware of this and have given me a task to perform in JavaScript tomorrow for me to prepare for.

They've told me to: "Converte SQL script to JavaScript". That's all. They will provide the SQL script and I have to convert it to JavaScript. No PHP/Ajax/server side language.

Can you please give me some relevant information or website that can point me in the right direction? Thank you for looking into this!

If I understand the question correctly, you somehow need to manipulate or manage data within JavaScript the same way a database would interpret a SQL statement. If that is correct, then here is how I feel it could be done.

Using a SQL statement such as:

Code:

SELECT * FROM users WHERE active = 1 OR pass = "789" ORDER BY name LIMIT 3

Thanks for that! I think you're right, this must be how they'll phrase a question. Thanks for taking the time and typing out all this!

Originally Posted by bionoid

If I understand the question correctly, you somehow need to manipulate or manage data within JavaScript the same way a database would interpret a SQL statement. If that is correct, then here is how I feel it could be done.

Using a SQL statement such as:

Code:

SELECT * FROM users WHERE active = 1 OR pass = "789" ORDER BY name LIMIT 3

The queries given were too many and included all kind of things from ROW_NUMBER () OVER (PARTITION BY, INNER JOIN, STRFTIME_USEC(ABC_Campaigns.campaign_expire_date * 1000, '%Y-%m-%d') > TODAY etc to name a few.

They had actually give a large chunk of their current working code and asked me to convert it to JS.

I could only do a bit and left out many things like ROW_NUMBER () OVER (PARTITION BY and STRFTIME_USEC which I did not even have time to research and understand. I had only 1.5 hours which was no where near enough the content they wanted me to cover.

With all that said, I did my best and gave most of my code in comments as otherwise it would not run. They later told me that they did not expect a working html file or for me to complete the whole thing. They just wanted too see how I'd attempt to convert it.

Lets see what happens. Either ways, thanks a lot for your help!

Originally Posted by bionoid

I would be very interested to know how things turn out, what was the question and what kind of results they were looking for.