This is strange.
I am moving a stored proc to a service. The TSQL unions multiple selects. To replicate this I created multiple queries resulting in a common new concrete type. Then I issue a return result.ToString(); and the resulting SQL selects have varying numbers of columns specified thus causing an MSSQL Msg 205...
using (var db...
What I want to do is implement submission scoring for a site with users voting on the content, much like in e.g. reddit (see the 'hot' function in http://code.reddit.com/browser/sql/functions.sql). Edit: Ultimately I want to be able to retrieve an arbitrarily filtered list of arbitrary length of submissions ranked according to their sc...
I would like to do a multiple search query usig multiple checkboxes which represent particular textboxes.
How do i create a mysql query which will be filtering the checked and unchecked checkboxes (probably using if statements)?
The query should be able to filter the checked and ucnchecked boxes and query them using the AND condition. ...
I'm looking to replace our current model (written entirely in Tcl (please don't even start)) with a new model based around an SQL (sqlite) database, and I'm looking for books/articles giving advice on how one goes about designing a DB schema as well as the model interface around it.
I've been reading questions about updating bad DB sche...
Here's the query:
INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06')
The datatypes are all correct, it always fails at the subject, so it must be how I'm escaping the ...
So I have a users table where the user.username has many duplicates like:
username and Username and useRnAme
john and John and jOhn
That was a bug and these three records should have been only one.
I'm trying to come up with a SQL query that lists all of these cases ordered by their creation date, so ideally the result should be somet...
Hey guys,
I am using pawn script for something, and everything works great except for one of my queries. For some reason, it will not work, and I am hoping it is simple enough someone can spot my mistake as I have been banging my head on it for days.
http://ampaste.net/m6a887d30
The two highlighted lines are the queries that are not w...
hi,
I have two tables with following definition
TableA TableB
ID1 ID2 ID3 Value1 Value ID1 Value1
C1 P1 S1 S1
C1 P1 S2 S2
C1 P1 S3 S3
C1 ...
I have a table of heterogeneous pieces of data identified by a primary key (ID) and a type identifier (TYPE_ID). I would like to be able to perform a query that returns me a set of ranges for a given type broken into even page sizes. For instance, if there are 10,000 records of type '1' and I specify a page size of 1000, I want 10 pair...
I'm messing around with SQLite for the first time by working through some of the SQLite documentation. In particular, I'm using Command Line Shell For SQLite and the SoupToNuts SQLite Tutorial on Sourceforge.
According to the SQLite datatype documentation, there are only 5 datatypes in SQLite. However, in the two tutorial documents abov...
How would you update data in multiple tables using a single query?
MySQL Example
The equivalent code in MySQL:
UPDATE party p
LEFT JOIN party_name n ON p.party_id = n.party_id
LEFT JOIN party_details d ON p.party_id = d.party_id
LEFT JOIN incident_participant ip ON ip.party_id = p.party_id
LEFT JOIN incident i ON ip.incident_id = i.i...
Hi,
I have a Tour object which has many Place objects. For the list of tours, I want to show some info of the tour, the number of places of the tour, and three Place's images. Right now my SQL queries are (i'm using Doctrine with Symfony on MySQL)
get Tour
get Tour 1 places
get Tour 2 places
get Tour 3 places
...
get Tour n places
If...
I have been testing my geolocation query for some time now and I haven't found any issues with it until now.
I am trying to search for all cities within a given radius, often times I'm searching for cities surrounding a city using that city's coords, but recently I tried searching around a city and found that the city itself was not re...
I need to update about 250k rows on a table and each field to update will have a different value depending on the row itself (not calculated based on the row id or the key but externally).
I tried with a parametrized query but it turns out to be slow (I still can try with a table-value parameter, SqlDbType.Structured, in SQL Server 2008...
I have a table with the following structure:
id -int(11)
event_id -int(11)
photo_id -int(11)
created_at -datetime
How do I write a query that will return the 100 most recent rows, but insuring that there are no more than 4 consecutive rows with the same value in photo_id
...
If this were raw-SQL, it'd be a no-brainer, but in Django, this is proving to be quite difficult to find. What I want is this really:
SELECT
user_id
FROM
django_comments
WHERE
content_type_id = ? AND
object_pk = ?
GROUP BY
user_id
It's those last two lines that're the problem. I'd like to do this the "Django-way" but the o...
Do you know of any open source library or framework that can perform some basic validation and escaping functionality for a MySQL Db.
i envisage something along the lines of:
//give it something to perform the quote() quoteInto() methods
$lib->setSanitizor($MyZend_DBAdaptor);
//tell it structure of the table - colnames/coltypes/ etc
...
hi guys
I am trying to get the total count and total sum per salesperson but its not working in my WITH query
Currently I have:
WITH CALC1 AS (
SELECT B.OTSMAN AS SALESMAN, COUNT(B.ONINUM) AS COUNT, SUM(B.OVSVAL) AS SVAL
FROM @[email protected] AS B
WHERE B.OCSGRP <> 'INT' AND
B.OCSGRP <> 'INX' AND
B.OCPSB...
Is it possible to change a column type in a SQL Server 2008 database from varchar(255) to varchar(MAX) without having to drop the table and recreate?
SQL Server Management Studio throws me an error every time I try to do it using that - but to save myself a headache would be nice to know if I can change the type without having to DROP a...
I can select using or with the sql statement
select f.userid, f.friend_userid from friends f where userid = 1 or friend_userid = 1;
now either userid or friend_userid is returning 1.
i want the two columns i.e userid and friend_userid to get merged
into a single column without 1
such that only one row is displayed...
the output i ...