Skip to content

Tag: sql

Prevent operational risk with SQL-dependent architecture

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…

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, …

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…