I have a string which contains a comma delimited list of id's which I want to use in a where clause.
How can I achieve this? Essentially I have:
set @ids = '5,8,14,5324,'
SELECT * FROM theTable WHERE Id IN (@ids)
but @ids is a varchar and Id is an int.
Any ideas much appreciated.
...
I'm a little stumped as to get the order of records I want with a find operation.
Let's say you had three models:
1. Websites
2. Links
3. Votes
A website has many links and a link has many votes. Each vote has a certain amount of points that a user can attribute to that vote. I'm trying to get a website index page where websites are li...
Hi
I am not sure if the transaction log is what I need or what.
My first problem is that I have a stored procedure that inserts some rows. I was just checking out elmah and I see that some sql exceptions happens. They all are the same error(a PK constraint was violated).
Other than that elmah is not telling me much more. So I don't k...
I asked a similar question the other day but it seems no one was able to answer it, and searched the internet for a few days but still fruitless, perhaps I am not asking the question the right way: http://stackoverflow.com/questions/3444718/one-to-many-query-in-mysql
So I while try again and maybe word it a bit differently. This is ess...
Hi I would like to create a SQL to group the records according to the range
For example, suppose I have
Number Time Price
100 20100810 10.0
100 20100812 15.0
160 20100810 10.0
200 20100810 12.0
210 20100811 13.0
300 20100811 14.0
350 2010081...
I am more than a little confused with an issue I have encountered 3 times in the past 2-3 months. The title of this question outlines the issue, but for more detail:
I have an SP which always returns results without issue when executed through SQL Server Mgmt. Studio, however very rarely (but enough to cause major headaches)- it will si...
I have a table T with columns A,B,C & D as below:
A,B,C,D
A1,B1,USD,LIBOR
A1,B2,JPY,FIXED
A2,B3,USD,LIBOR
A2,B4,EUR,FIXED
A3,B5,JPY,FIXED
A3,B6,USD,LIBOR
Table always has 2 rows per "A", with different values of "B".
"B" is unique
"A" - varchar(10), "B" - varchar(8), "C" - varchar(3), "D" - varchar(5)
Validation rules restrict th...
Hey guys
I have a stored procedure which does not need to return any values. It runs smoothly and without any problem. However, it outputs an error message (Error: No data - zero rows fetched, selected, or processed) after finishing its run. How can I get rid of this error message?
(It is a simplified version of the procedure so, please ...
I have a small db app that stores URL's of all lengths, some extremely long (hundreds of characters) and some of typical length (< 50 characters). Am I introducing inefficiencies into the DB by declaring VARCHAR(1000) (or higher) as the type? Is there something better to use?
...
Well interesting to me at least...
Say I have two tables:
myLookUpTable:
lookupId | Name
-------- -----
1 Red
2 Green
3 Blue
and InfoTable:
infoId lookupId Amount ParentId
------ -------- ------ --------
1 1 2 332
2 3 14 332
How would I write a query t...
I could really use some help optimizing a table on my website that is used to display rankings. I have been reading a lot on how to optimize queries and how to properly use indexes but even after implementing changes I thought would work, little improvement can be seen. My quick fix has been simply to use only the top 100,000 rankings (...
I have a table with 5 columns:
tag 1
tag 2
tag 3
tag 4
tag 5
If I want to show results ordered by the popularity(frequency) of those tags, what kind of query would i use?
...
I'm trying to do something like this:
SELECT t1.*,
t2.*
FROM (SELECT *
FROM USER) AS t1,
(SELECT *
FROM t1) AS t2
It doesn't work in MySQL. Is something like the above possible? My other option is to take the last subsquery and "wrap" it around the main query. Ideas?
...
Now, I'm pretty sure that it's not possible, but I want to 1) Confirm this, and 2) Hear alternatives.
My solution today was to run the MySQL query, then use its result to construct a "NOT IN ('value1', 'value2', 'value3')" string, which I tacked onto the Oracle query before running it. Rather cumbersome, but it worked, and it's fast eno...
Currently I am doing one query, with 3 sub queries,
all queries are on the same table,
all queries have different where clauses
I have thought about doing a group by however this would destroy the SUM()
here is the query
SELECT SUM(club) AS club,
(SELECT COUNT(id) FROM action_6_members WHERE SUBSTR(CODE, 1, 1) = '9') AS 5pts,
(SELE...
Does anyone know the range comparison of the BETWEEN clause? if I have a datetime datatype, does the BETWEEN clause compare until hour/minute/second level?
...
This is the output I got from my query. You can see Monthly sales for 1997 is followed by monthly sales of 1998. (It might not show in proper format here but they are all in a row)
Month Year Sales
---------------------------
1 1997 61258.07045
2 1997 38483.63504
3 1997 38547.21998
4 1997 53032.95254...
I'm updating a Postgres 8.4 database (from C# code) and the basic task is simple enough: either UPDATE an existing row or INSERT a new one if one doesn't exist yet. Normally I would do this:
UPDATE my_table
SET value1 = :newvalue1, ..., updated_time = now(), updated_username = 'evgeny'
WHERE criteria1 = :criteria1 AND criteria2 = :crite...
Please can someone tell me how to connect to sql server 2000 with asp page using vb?
...
I'm working on migrating my company from VSS to SVN for SVM. We develop tools for use by our business that live within a central web application. Right now our setup is as follows:
The Java developers develop and test locally, and once complete, check their files into VSS. Their local code points to a stage SQL instance. Once or twic...