Hi,
I run a website where users can post items (e.g. pictures). The items are stored in a MySQL database.
I want to query for the last ten posted items BUT with the constraint of a maximum of 3 items can come from any single user.
What is the best way of doing it? My preferred solution is a constraint that is put on the SQL query re...
I was reviewing some SQL queries and I saw a select statement that looked like this
SELECT *
FROM dbo.mytable
WHERE (dbo.mytable.[Date] < { fn NOW() })
What is the purpose of using a WHERE statement like this?
Wouldn't be easier to use a simple GETDATE()?
...
Hi to all, I've got a particular SQL statement which takes about 30 seconds to perform, and I'm wondering if anyone can see a problem with it, or where I need additional indexing.
The code is on a subform in Access, which shows results dependent on the content of five fields in the master form. There are nearly 5000 records in the table...
Suppose I have a SELECT statement that returns some set of results. Is there some way I can number my results in the following way:
SELECT TOP 3 Name FROM PuppyNames ORDER BY NumberOfVotes
would give me...
Fido
Rover
Freddy Krueger
...but I want...
1, Fido
2, Rover
3, Freddy Krueger
where of course ...
Does anyone know of a tool that can verify that a given SQL statement is valid across different databases (oracle, db2, mssql)?
...
I've got an SQL query that looks like this:
INSERT INTO DB..incident
(
incident_number --nvarchar(10)
)
VALUES
(
N'I?'
)
What does the ? do in the value statement?
EDIT:: Turns out there's some funny business via triggers and custom datatypes that occur on insert (we've got a bit of a messed up DB.) Given normal sett...
I need to know how to return a default row if no rows exist in a table. What would be the best way to do this? I'm only returning a single column from this particular table to get its value.
Edit: This would be SQL Server.
...
Hey all,
I know you can combine multiple table-selects using a Join statement but is there a way to combine these two queries into one?
SELECT Statistics.StatisticID
FROM Statistics
ORDER BY `SubmittedTime` DESC
LIMIT 0, 10
And this one?
SELECT COUNT(Votes.StatisticID)
FROM Votes
WHERE Votes.StatisticID = ?
(fluff removed)
At th...
I have a table of transactions which will occasionally have
duplicate entries. If/When an admin finds these duplicate entries, they will reverse the transactions, therefore creating a negative value (but the original duplicate still remains due to regulatory requirements). I'd like to create a SQL query (and use Crystal Reports) to make...
I'm trying to insert multiple rows, one after another, to a database. Here is the relevant code.
Private ConnectionString As String = "Provider=OraOLEDB.Oracle;Data Source=(DESCRIPTION=(CID=GTU_APP)(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx)(PORT=xxx)))(CONNECT_DATA=(SID=xxx)(SERVER=DEDICATED)));User Id=xxx;Password=xxx;"
Private SQ...
I have an Informix SQL query which returns a set of rows. It was slightly modified for the new version of the site we've been working on and our QA noticed that the new version returns different results. After investigation we've found that the only difference between two queries were in the number of fields returned.
FROM, WHERE and OR...
I have an excel page that runs a series of web queries that call reporting services reports and thencut-n-paste that into powerpoint. from time to time, the query hangs and brings the app to a screeching halt. is there a way to maybe put that into a loop and keep looping until the web query actually brings back some data?
...
I have a DataGridView that I want to query using Linq (C# WinForm). I want to "count" rows where a certain criteria is met. For example,
variable1 = "count rows where ColumnBoxAge > 3 || < 5"
label1.Text = variable1
How to do this in C# WinForm using Linq?
...
In my php script which connects to mysql, I have to query 2 databases in the same script to get different information. More specifically Faxarchives in one database and Faxusers in the other.
In my code I query faxusers and then foreach user, I query Faxarchives to get the user history.
I might do something like:
function getUser...
Hi,
I want to select about 4-5 rows from a table, then form a space separated string.
All of this is to be done in a stored procedure (SQL server 2005).
Is this possible?
I will then use this space-separated string and save it to another table.
Update
SELECT *
FROM Users
WHERE userID < 10
output:
john
jake
blah
sam
So, put thi...
I'm writing an application in PHP 5. I want to delete some rows in a SQLite v2 database file. I'm doing something like this:
$sqliteConnection = new SQLiteDatabase('path/to/db');
$queryString = "DELETE FROM myTable WHERE status='not good'";
$result = $sqliteConnection->query($queryString);
how can I know how many rows were affected by...
I have a database that i'm dealing with which is updated every few hours remotely (not on any specific time span) and i have no control over the administration of it. I have web clients connecting to it to view information contained within it. These clients (coded using PHP and Javascript) might be checking the database very often (impat...
Just wondering if there is anything built-in to Javascript that can take a Form and return the query parameters, eg: "var1=value&var2=value2&arr[]=foo&arr[]=bar..."
I've been wondering this for years.
...
I mainly use the MySQL GUI tools. This allows me to easily see the results in a table as well as to quick edits and bookmark frequently run queries. This suits my needs far better than the command line.
I remember when I used to do this on Oracle DBs years ago I could put variables in the query itself, so that when running the query I g...
When executing the following (complete) SQL query on Microsoft SQL Server 2000:
SELECT B.ARTIFACTTNS, B.ARTIFACTNAME, B.ARTIFACTTYPE, B.INITIALBYTES, B.TIMESTAMP1, B.FILENAME, B.BACKINGCLASS,
B.CHARENCODING, B.APPNAME, B.COMPONENTTNS, B.COMPONENTNAME, B.SCAMODULENAME, B.SCACOMPONENTNAME
FROM (SELECT DISTINCT A.ARTIFACTTYPE, A.A...