Hi I'm new to SQL and I'm trying to figure out how I'm going to get the top 5 "bands" with most friends (userId) and this is what i have; a usertbl with userId as PK then a bandsTbl with bandId as PK then I have a table bandfriends with FK userId and bandId.
bandfriends
userid | bandId
---------------
1 | 1
1 | 2
1 | 3
...
Q: How do I make MySQL only SELECT all users that have played => x amount of games within the y most recent days?
This is all used for a gaming ladder. I use two tables: weblPlayers has only the user info (username, email, password etc), and weblGames has the result of every reported game along with the date and time, properly formatted...
I have an Access 2007 database that uses the "Attachment" datatype (new in Access 2007) for one of its field. This field is a magical "multi-valued" field that can contain several attachments.
I would like to be able to easily see the contents of this field, for all the rows in the database, using a single ODBC query. Ideally, each ro...
My "FeedbackSummary" table structure is
GivenBy varchar(50)
GivenTo varchar(50)
Points decimal(15, 2)
Sample Data
Alice Janet 4.50
Alice Bruce 3.50
Bruce Alice 2.87
Bruce Janet 4.75
Janet Alice 5.45
Janet Bruce 3.78
What I am trying to achieve
GivenBy_GivenTo Alice Bruce Janet
Alice NULL 3.50 4.50
Bruce 2.87 ...
I can create a table and its columns in Java by using the statement:
CREATE TABLE table_name(column1 int, column2 double, etc...)
What I would like to do is to add descriptions to each of these columns with an appropriate statement, I found a stored procedure sp_addextendedproperty that looks like it can be used to accomplish this I j...
Hello.
I am trying to write an sql query and I am having a problem. When we want to write a query with a where clause to narrow down our results, we can do
... where name = 'John'
(Where name is a column in the table).
Now I am trying to insert a clause like this except the name is "O'Malley". So I thought the query would be
... whe...
I am having trouble writing a query to select one row per "date", given certain conditions. My table has this structure:
ID date expiration callput iv delta
1 1/1/2009 1/20/2009 C 0.4 0.61
2 1/1/2009 1/20/2009 C 0.3 0.51
3 1/1/2009 2/20/2009 C 0.2 0.41
I woul...
Hi,
I currently have a table with a column as varchar. This column can hold numbers or text. During certain queries I treat it as a bigint column (I do a join between it and a column in another table that is bigint)
As long as there were only numbers in this field had no trouble but the minute even one row had text and not numbers in t...
I'm wondering whether such query could be potentially optimized.
I've hugely simplified it, and you see the core of it.
with Rec (Id,Name,ParentId)
as
(
select Id,Name,ParentId from Departments where ParentId is null
union all
select d.Id, d.Name, d.ParentId from Departments d join Rec r on
(d.ParentId=r.Id)
)
select q....
Hi.
I am starting a new project, and I am considering using alias data types in my SQL Server 2005 database, for common table columns. For e.g. I would define an alias data type to hold the name of an object, as follows:
CREATE TYPE adt_Name FROM
varchar(100) not null
Then use it for the definition of table columns, ensuring a...
I want to run a query similar to this one on a SqlCE database:
SELECT t.Field1, t.Field2
FROM MyTable t
WHERE t.Field1 = @Param
UNION ALL
SELECT t2.Field1, t2.Field2
FROM MyOtherTable t2
WHERE t2.Field1 = @Param
However, running this results in the error message:
Duplicated parameter names are not
allowed. [ Parameter name = @P...
How do I display, edit and save an Excel sheet data in sql server?
Any help would be appreciated.
...
I have two date values: 08/6/2009 00:00:00 and 10/6/2009 23:59:59.
How do I get the difference in hours in a query in SQL Server 2005?
...
I have been playing around with the idea of a single audit table for a few tables in my database. I found the code on this page: http://www.simple-talk.com/sql/database-administration/pop-rivetts-sql-server-faq-no.5-pop-on-the-audit-trail/
I like the idea, but the only that I am a bit puzzled with is how you would query out the informa...
Hi all,
I'm using the SQL command below to update a column called Address, the value contains line feeds and I want to replace them with a semi-colon. In Query Analayzer the preview looks perfect but when I check the data in Enterprise Manager (MS SQL 2000) I still see the squares i.e. the line feeds. Am I not commiting the change? Wher...
Hi,
I've had this problem a few times and solved it the same way. But it's not pretty and I was wondering if anyone knew of anything a bit more elegant...
The Basic Aim:
- I have a piece of code that is common through-out many Stored Procedures.
- For maintenance purposes I like modularity.
- So I want to put that common code in it's o...
1) If I am running a find and replace in SQL 2005 - what would be the regular expression to find tab and space sequences ( or space and tab sequences ) and replace them with just tab?
2) If I have a line which begins with a space - is there a regular expression to convert that leading space to a tab?
3) What would be the regular expres...
I have the following private method in my form :
function _verifywebsite ($id) {
$row = $this->websites->fetchRow("id=$id");
$row->verified_date = $this->_get_date(); // this is the line in question
$row->save();
}
I assume that $row requires me to enter date as string value in correct date format.
But what if I want to includ...
I have a database log appender that inserts a variable number of log lines into the database every once in a while.
I'd like to create an SQL statement in a way that prevents SQL injection, but not using server-side prepared statements (because I have a variable number of rows in every select, caching them won't help but might hurt perf...
I have a single solution with multiple database projects and an SSIS projects. The entire build and deploy portion takes a few minutes especially because we deploy unit test data along with the build.
Does Visual Studio 2008 allow me to display timestamps the output window of the build so I can keep track of things?
I know I can execut...