I am currently working on a very critical tool, which has a strong dependency to a MySQL database. This particularly means that if the SQL server goes down some day, all users won’t be able to use the application, since it is retrieving their configuration stored in database and launches components defi…
Tag: sql
How to use “Partition By” or “Max”?
I’ve the following table (my_data): what is the best / smallest SQL statement to retrieve only the data related to the highest year and grouped by ‘X’ , like this: Note that this result table will be used in a join. Answer
How to print SQL statement in codeigniter model
I have a sql statement in my model, I then say My query always fails, how do I get php to print the exact sql statement being sent to my database? And display that on my php view, page Answer To display the query string: To display the query result: The Profiler Class will display benchmark results, queries y…
Simple DateTime sql query
How do I query DateTime database field within a certain range? I am using SQL SERVER 2005 Error code below Note that I need to get rows within a certain time range. Example, 10 mins time range. Currently SQL return with Incorrect syntax near ’12’.” Answer You missed single quote sign: Also, …
Using a conditional UPDATE statement in SQL
I would like to have an UPDATE statement like this: SELECT * FROM Employee WHERE age = CASE WHEN (age < 20) THEN age=15 WHEN (age > 20) THEN age= 20 Is this not possible in SQL Server / …
How to send multiple data fields via Ajax? [closed]
I’m stuck: I’m trying to submit a form using AJAX, but I can’t find a way to send multiple data fields via my AJAX call. $(document).ready(function() { $(“#btnSubmit”).click(function() { var …
Syntax of for-loop in SQL Server
What is the syntax of a for loop in TSQL?
SQL Server 2008 – How to convert GMT(UTC) datetime to local datetime?
I have an insert proc that passes in GETDATE() as one of the values because each insert also stores when it was inserted. This is hosted on SQL Azure – which uses GMT. Now, when I am receiving messages, I have the GMT date stored for each of them in their timestamp columns, how do I convert this to the
Select a list of keys of a table in MySQL
Say I have a table “products” and I would like to check if this table has any indexes, foreign keys etc A “DESCRIBE products” would give some information. Mainly the key field in the case. But defenietly no references and what table is linked to who etc etc. What is the best way to get…
How can I group by date time column without taking time into consideration
I have a bunch of product orders and I’m trying to group by the date and sum the quantity for that date. How can I group by the month/day/year without taking the time part into consideration? 3/8/2010 7:42:00 should be grouped with 3/8/2010 4:15:00 Answer Cast/Convert the values to a Date type for your …