I want to access a MySQL database and I want to read+write data from+to the database within my Qt/C++ program. For the read write process, I try to use QSqlTableModel, QSqlTableRcord and QSqlDatabase as this is a very pleasant approach without too much of SQL commands which I dislike for the one or other reason (to handle myself).
I got ...
Is it possible to run multiple stored procedures that run 'in the background'?
The stored procedures must be launched from a single, master stored procedure, in the same way that multiple worker threads are spawned. For example:
CREATE PROCEDURE MyLauncher
AS
BEGIN
BEGIN
@EXEC MyBackgroundSP01 -- Runs in parallel to the othe...
In an SQL table I keep bookings for various resouces, with a StartDate/EndDate column:
ResourceID, StartDate, EndDate
-----------------------------------
1 2009-01-01 2009-01-05
1 2009-01-07 2009-01-10
2 2009-01-03 2009-01-18
I need to produce a list of all resources that are available for at lea...
SELECT user_id, created FROM photo_comments GROUP BY user_id
returns
user_id created
1 2009-10-20 21:08:22
12 2009-10-20 21:45:00
16 2009-10-28 20:35:30
But that created date of 2009-10-20 for user id 1 is the first entry by user id 1.
How can I get the last entry by user id 1? (date should be 2009...
I get that the (nolock) optimizer hint allows for "dirty reads", but under what very specific scenarios is this a bad idea? I've never seen such widespread use of (nolock) in an organization, and it makes me nervous. I'd like an explanation in terms of user stories. "Paul does A, Peter does B, X happens instead of Y".
...
I have a query:
select event_type,
department_name,
effective_time,
row_number() OVER (PARTITION BY event_type,department_name ORDER BY effective_time) row
from a
order by effective_time
It returns a row set:
event_type department_name effective_time
3 A 02/10/09 13:12:00
3 B 02/10/09 15:44:00
3 B 02/10/09 20:...
Given the following schema:
CREATE TABLE players (
id BIGINT PRIMARY KEY,
name TEXT UNIQUE
);
CREATE TABLE trials (
timestamp TIMESTAMP PRIMARY KEY,
player BIGINT,
score NUMERIC
);
How would I create a SELECT that first finds the best scores from trials, then joins the name field from users? I've been able to get the score...
I was wondering if it is bad practice to have a file_table { id, name, status} and a extra_data table { id, fileId FK(file.id), otherData}. So far all my tables go forward and I never needed to get the id of one table then do a query to get more data using an id.
Is this bad practice and if so then why?
...
I'm trying to create an SQL query to work out the percentage of rows given its number of play counts.
My DB currently has 800 rows of content,
All content has been played a total of 3,000,000 times put together
table:
*id, play_count, content*
Lets say I'd like to work out the percentage of the first 10 rows.
My attempts have looked ...
hi
1) The following query obtains from each film category the cheapest
possible DVD with the highest rating:
SELECT FilmName, Rating, DVDPrice, Category
FROM Films AS FM1 INNER JOIN Category AS C1 ON C1.CategoryId = FM1.CategoryId
WHERE FM1.DVDPrice =
(SELECT MIN(DVDPrice)
FROM Films AS FM2
WHERE FM2.DVDPrice IS NOT...
What would be the best way to find dates that dont have events in a given time interval given that different events can overlap, span multiple days, start before the interval, and end after the interval.
ie:
event start end
e1 01/01/2009 02/01/2009
e2 01/15/2009 01/31/2009
e3 08/15/2008 01/16/2009
e4 ...
I am creating a class that handles various SQLite actions. My problem is: When I make a SQL string with multiple statements then it works when using standard PHP => $db->query() ... but it fails when making the same request from a method. It seems that the OO method skips everything after the first ";"-symbol in my SQL statement. Why is ...
Our application has started having problems with SQL Server 2005 queries getting blocked. Is is possible to tell what query the blocking process is running? If it is possible how is it done?
...
I use Linq to Sql Compact with code generated by sqlmetal. When I open an invalid database, like eg an mp3, I can create the DataContext without getting an Exception. But when I query any data or call DatabaseExists, the application hangs. Why is no exception thrown? Is this a known problem?
...
(Note: this is for MS SQL Server)
Say you have a table ABC with a primary key identity column, and a CODE column. We want every row in here to have a unique, sequentially-generated code (based on some typical check-digit formula).
Say you have another table DEF with only one row, which stores the next available CODE (imagine a simple ...
I've been reading about SQL injection attacks and how to avoid them, although I can never seem to make the "awful" examples given work, e.g. this post
http://stackoverflow.com/questions/332365/xkcd-sql-injection-please-explain
I created a php file and a table in the database, had a value passed through $_GET and tried to delete the tab...
I am writing a migration generator for a plugin I am writing and I need to to be able to find what unique indexes a table has so I can modify existing unique indexes to become a composite unique index. I have been trying to find a way to access what indexes a table has with ActiveRecord. I have only been able to find ActiveRecord::Conn...
I'm not quite sure what this is called, but I've spent some time thinking about it and I'm not sure how to approach it. I'm sure it's really simple.
I have two tables, foo and bar. They're related like this:
Foo Table:
| id | name
--------------
| 1 | blah
| 2 | blarg
| 3 | blag
Bar Table (the meaning of baz is irrelevant)...
Alright I need to do a big query, but I only want the latest records.
For a single entry I would probably do something like
SELECT * FROM table WHERE id = ? ORDER BY date DESC LIMIT 1;
But I need to pull the latest records for a large (thousands of entries) number of records, but only the latest entry.
Here's what I have but It's no...
I am using a set of SQL LIKE conditions to go through the alphabet and list all items beginning with the appropriate letter, e.g. to get all books where the title starts with the letter "A":
SELECT * FROM books WHERE title ILIKE "A%"
That's fine for letters, but how do I list all items starting with any number? For what it's worth th...