query

Linq to SQL Nested IN FROM query

Can anyone tell me how to write a nested SQL query like SELECT * FROM X WHERE X.ID IN (SELECT Y.XID FROM Y WHERE .....) in LINQ? ...

Querying a table to get values based on no of digits of a parameter?

Hi, Considering the following table I have a large table from which I can query to get the following table type no of times type occurs 101 450 102 562 103 245 111 25 112 28 113 21 Now suppose I wanted to get a table which shows me the sum of no of times type oc...

How do I write a string search query that uses the non-clustered indexing I have in place on the field?

I'm looking to build a query that will use the non-clustered indexing plan on a street address field that is built with a non-clustered index. The problem I'm having is that if I'm searching for a street address I will most likely be using the 'like' eval function. I'm thinking that using this function will cause a table scan instead o...

Pattern for compile time discovery of unsafe/wrong queries

My team is developing a large java application which extensively queries a MySQL database (in different classes and modules). I'd like to known if there is a pattern that allows me to be notified at compile time if there are queries that refer to a wrong table structure (for instance if I remove or add a field on a table and the query s...

Parametise table name in .Net/SQL?

As the topic suggests I wish to be able to pass Table Names as Parameters using .Net (doesn't matter which language really) and SQL. I Know how to do this for values, i.e command.Parameters.AddWithValue("whatever",whatever). Using @whatever in the query to denote the Parameter. The thing is I am in a situation where I wish to be able to...

Insert Dates in the return from a query where there is none.

We are building a query to count the number of events per hour, per day. Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these. We still want to show the hours that do not have activity and display a zero so tha...

MSAccess: SELECT INTO NewTable cuts long texts

When I use (in MS Access 2003 SP3): SELECT * INTO NewTable FROM SomeQuery; MEMO fields are converted to TEXT fields (which are limited to 255 characters), so longer texts are cut. The output of the query itself is fine and not truncated; the text is cut only in the new table that is created. An update: I managed to focus the proble...

Access: to export fields to excel based on a query

I am looking to export a few files into Excel from MS Access based on querying a table. It's like this the query will be select * from table where field = 0 I would like to loop the query till field is 9 and I want to save each result in a different name like field1, field2 How will this have to be modified? strqry = "select ...

How do I select only the latest entry in a table?

I have a 3 table SQLServer Database. Project ProjectID ProjectName Thing ThingID ThingName ProjectThingLink ProjectID ThingID CreatedDate When a Thing is ascribed to a Project an entry is put in the ProjectThingLink table. Things can move between Projects. The CreatedDate is used to know which Project a Thing was last moved too. I ...

SPARQL Query, select everything except things that match?

I am getting comfortable writing regular queries in SPARQL, but I'm still having trouble with fancier stuff. My latest problem is trying to select everything except stuff that matches the where clause. For instance, say I want to find all the husbands who like a car color that their wife doesn't like (I'm working on a proprietary model...

How to get browser type and version from within an applet?

Is is possible to query the current browser from within an applet? I would like to know if the current browser is IE6 or IE7. ...

How to select a large amount of records in SQL SERVER

I'm trying to select more than 80,000 record in SQL Server in a table that has millions of records. The issue is that I've the correct Index, but it takes more than 15 minutes to return the recordset. I'm using MS SQL Server 2000, I found a pagination method using stored procedures but it uses a temporal table that I have to insert the ...

Insert Parameterized Query ASP.NET MS SQL

Here is my SQLCommand object: oCommand.CommandText = "INSERT INTO hits (id,client_id,client_ip,page,vars) VALUES _ (@@IDENTITY,@client_id,@ip,@page,@vars)" oCommand.Parameters.Count = 4 >> oCommand.Parameters.Item(0).ParameterName = "@client_id" >> oCommand.Parameters.Item(0).Value = "123456" >> oCommand.P...

Looking for advice on a "related videos" query on a tagged video system

Well I run a small video website and on the actual video page there is a strip of "related videos" similar to most video sides (e.g. YouTube) and currently all I'm doing is taking one of its tags randomly and finding other videos with the same tag. Not surprisingly this isn't a great method as some tags are very vague and some videos ar...

MySQL schedule conflicts

Hey, I stumbled upon this site looking for solutions for event overlaps in mySQL tables. I was SO impressed with the solution (which is helping already) I thought I'd see if I could get some more help... Okay, so Joe want's to swap shifts with someone at work. He has a court date. He goes to the shift swap form and it pull up this week'...

How do I compare overlapping values within a row?

I seem to have a problem with this SQL query: SELECT * FROM appts WHERE timeStart >='$timeStart' AND timeEnd <='$timeEnd' AND dayappt='$boatdate' The time is formatted as military time. The logistics is that a boat rental can be reserved at 7am til 1pm or 9am til 1pm or 9am til 5pm. If there is an appt within that range, it should ...

Need help on selecting items in simple database in python.

I'm trying to write a circuit schematic drawing tool in Python. I'm creating a simple database based on dictionaries which holds all the components and their properties. I'm also trying to create a simple query language where you can select, for example, all resistors with value>100ohms or footprint='0402' So far, I can select thing...

How to put more than 1000 values into an Oracle IN clause

Is there any way to get around the Oracle 10g limitation of 1000 items in a static IN clause? I have a comma delimited list of many of IDs that I want to use in an IN clause, Sometimes this list can exceed 1000 items, at which point Oracle throws an error. The query is similar to this... select * from table1 where ID in (1,2,3,4,...,...

Find missing values

I have a table, with 2 important columns DocEntry, WebId Sample data is like DocEntry WebId 1 S001 2 S002 3 S003 4 S005 Now as we can notice here, in column WebId, S004 is missing. How can we locate such missing numbers, with a query. Further explanation: The web id should be in increasing order lik...

using results from a sql query in a python program in another sql query

hi, sorry for my previous question which was very ambiguous, but i think if i get the answer to this question I can work it out. In the program below i have selected the barcodes of products where the amount is less than the quantity. I want to say, that if the barcodes(in the fridge table) match barcodes in another table(products), set ...