query

How to query from a stored procedure in SQL Server?

Let say I have a simple Stored Procedure: ALTER PROCEDURE [dbo].[myProc] AS BEGIN SELECT * FROM myTable END How can I do a WHERE statement in Microsoft SQL Server Management Studio to the stored procedure? Something like that: SELECT * FROM myProc WHERE x = 'a'; -- But that doesn't work... ...

How do you force linq to sql to use the correct data type for sql parameters?

I have a situation where a certain linq query that runs against a multi-million row table is taking far to long to run. I dissected the linq query output and found that it was creating the parameters for the where clause using the wrong data type. For instance, one field was defined as a Char(12) in the database, but the parameter it was...

Advanced indexing involving OR-ed conditions (pgsql)

I'm starting to get a much better grasp on PostgreSQL indexing, but I've run into an issue with the OR conditional, where I don't know how to go about optimizing my indexes for a faster query. I have 6 conditionals that, when run individually, appear to have a small cost. Here's an example of the trimmed queries, including query plan c...

cakephp save returns true but does not save

Hi, CakePHP is driving me nuts! Here is my code: if($this->Page->save($datavalue)) { $this->Session->setFlash('Page content updated successfully.'); } else { $this->Session->setFlash('Page content was not updated.'); } it always says updated successfully, but nothing is updated in the database. Here is the content of $datavalue: Ar...

Hibernate HQL: how to use a complex left join fetch

Hi all, I want to add a left join on TASK table when the following condition occurs: LEFT JOIN FETCH PROMPT p on (t.id = p.task.id and p.applicationName in ('XXX')) Here is my hql query: select distinct t from TASK t LEFT JOIN FETCH SERVER ser ...

Error while using Keyword Query object in asp.net application for search in sharepoint.

I am trying to use Keyword Query object in asp.net application. I wrote this code : Namespace : using System.Data.SqlClient; using Microsoft.SharePoint; using Microsoft.SharePoint.Search; using Microsoft.SharePoint.Search.Query; Page load event: GridView grd = new GridView(); ...

SQL get IDs that are available in the given time interval for X consecutive days

In an SQL table I keep bookings for various resouces, with a StartDate/EndDate column: ResourceID, StartDate, EndDate ----------------------------------- 1 2009-01-01 2009-01-05 1 2009-01-07 2009-01-10 2 2009-01-03 2009-01-18 I need to produce a list of all resources that are available for at lea...

Does the following query correct the problem?

hi 1) The following query obtains from each film category the cheapest possible DVD with the highest rating: SELECT FilmName, Rating, DVDPrice, Category FROM Films AS FM1 INNER JOIN Category AS C1 ON C1.CategoryId = FM1.CategoryId WHERE FM1.DVDPrice = (SELECT MIN(DVDPrice) FROM Films AS FM2 WHERE FM2.DVDPrice IS NOT...

hints on coding a dynamic form for mysql query

I'm a beginner and trying to generate as much of my own code as possible without just constantly asking others to write it for me, so with regard to this question I'm looking for hints in the right direction, rather than outright working examples. You people are all very talented, but I learn best if I reason it out myself. Should I hit ...

Cheap/free query tool for multi-database Java/hibernate developer

I'm very interesting in inexpensive (better free) SQL query tool for working with multiple databases. Generally speaking it should works with all databases which Hibernate supports, but it must work with Microsoft SQL Server (2000/2005/2008), Oracle (9i/10g/11g), Postgres 8.x, Sybase, Firebird, MySQL and HSQLDB. Must have features: ...

MySQL: Is there a way to LEFT JOIN conditionally? (or similar?)

I'm writing a query to get ALL of the products in the products table, and the sale price for each product IF a record exists for that item in the specials table. What I'm looking for is something like: SELECT * FROM products P IF (S.specials_date_available <= NOW() AND S.expires_date > NOW()) { // The sale has started, but has not yet ...

Searching a HDF5 dataset

Hi all, I'm currently exploring HDF5. I've read the interesting comments from the thread "Evaluating HDF5" and I understand that HDF5 is a solution of choice for storing the data, but how do you query it ? For example, say I've a big file containing some identifiers : Is there a way to quickly know if a given identifier is present in the...

NHibernate Search with inheritance ...

Hello guys... I have a Client class like that: public class Client { public Person Pers { get; set; } } And I have 2 Person´s child class : public class PersonType1 : Person { protected string att1; protected string att2; } public class PersonType2 : Person { protected string att3; protected string att4; } pu...

Priming read for PHP Query

I am new to PHP and working on my own CMS for a project. Mostly to just give myself a project to learn the language. The CMS is working but I am just tracking down some bugs in it. So here it goes... I am trying to list all of my published articles for each section. It does this correctly but I am having an issue in the code statemen...

Axapta: Find table by name in AOT

I would like to query the AOT to see if a table name exists using X++. Can anyone point me in the right direction or provide some sample code for doing that? If table exists with the name (str tableName) provided, return true; else, return false. Thanks ...

Returning unread records using Linq To SQL

I'm not sure how to ask this question, so I'll start with an example of what I'm doing. Here is my table structure... Documents (Primary key = ID) ID, Title, LatestApprovedRevID Revisions (Primary key = ID) ID, DocumentID, RevisionNum, Body Document_Reads (Primary key = DocumentID, UserName) DocumentID, UserName, RevisionID When a u...

MySQL command to search CSV (or similar array)

I'm trying to write an SQL query that would search within a CSV (or similar) array in a column. Here's an example: insert into properties set bedrooms = 1,2,3 (or 1-3) title = nice property price = 500 I'd like to then search where bedrooms = 2+. Is this even possible? ...

MySQL counting most common value

I have a MySQL database where users can list books they've read, want to read etc. I'm trying to write a query to find the most common book that users have listed. My current query is: $result = mysql_query("SELECT title, COUNT(title) AS counttitle FROM books GROUP BY title ORDER BY counttitle DESC LIMIT 1"); echo "<p>The ...

does ordering by lot of columns hit the performance badly?

I just ran into a SQL query with about 5 different columns in the ORDER statement, is it a good practice and how does it play with performance? ...

SQL select at least X rows that are in a given time

hello, i am looking for an SQL query, that selects exactly rows ordered by date from a table. for this there is a column that contains a timestamp. and here comes the tricky part: it should not select rows that are older than a certain time, but it should still select at least X rows. so if in the given time there are not more than X ...