where

SQL Question: It's possibile to have a WHERE clause after a HAVING clause?

So... It is possibile to use a WHERE clause after a HAVING clause? The first thing that comes to my mind is sub queries, but I'm not sure. P.S. If the answer is affirmative, could you give some examples? ...

oracle where in limitation to 1000 / hibernate

Oracle knows the limitation to 1000 elements in the where a in (..) clause. Does this limitation also exist when using Hibernate in conjuction with Oracle? ...

LinqDataSource - how do I select rows based on the current UserId?

Hello, I have a Grid View control that displays data based on what is returned by the LinqDataSource. The LinqDataSource selects data depending on the date chosen in a date control (used in the where clause), but I also need the where clause to be based on the current userID which is a GUID. How can I get the LinqDataSource to obtai...

How to do: sum columnB where columnA is XYZ - in Excel?

Hi I have a bunch of columns and some columns which are values I need to add. Lets say I want to sum columnB (which could be $) where column A is banana, how do I do that? Thing is I have a huge dataset and it is something that is going to keep changing. And besides banana, i might have apples, oranges, etc. And I want to sum the $ val...

Linq To Sql 'Where Or' operator

I need to create a query which checks if a field (string) contains one or more words supplied at run time. Basically I need to be able to ask a WhereOr question. This seems like it should be a common issue when dealing with LinqToSql. I found the following reference but can't make sense out of it - and have no idea how to use it in my...

Strange .Where() behaviour. Somebody has an explanation?

Original I don't get why the Where() clause doesn't give me the right results in the last example. It isn't any different is it? Why does C# behaves differently? transactions = IEnumerable<Transaction> //pseudocode //This works: It gives me the transaction I need. DateTime startDate = DateTime.Parse(parameter.Constraint); transactio...

Where clause variable for linqtosql from IDs in Stored Procedures.

Hi, I have created a function that retrieves values based on datepart of a datefield from a stored procedure: public List<spDB1GetIDsByTimeResult> GetIDsByTime(int timePart) { using (DB1DataContext db1= new DB1DataContext ()) { List<spDB1GetIDsByTimeResult> query = db1.spDBGetIDsByTime(timePart).ToList()...

Mysql SELECT narrowing search

EDIT:That was fast. The reason why I have this is because the table is a pivot table between 2 tables one has "id" as primary key and the other "type" primary key Hello. I want the following: Find only find "id" where "type" is 1 AND 2 AND 3 This is not working: SELECT * FROM `table` WHERE `type` = 1 AND `type` = 2 AND `type` = 3; ...

Oracle OCI: Problem in Query with Date field

Client compiled with OCI: 10.2.0.4.0 Server: Oracle9i Enterprise Edition Release 9.2.0.4.0 The problematic query is: SELECT CODIGO FROM LOG WHERE TEL = :telnumber AND DATE_PROC = '05-JUL-08' Table description: SQL>describe LOG; TEL NOT NULL VARCHAR2(15) CODIGO NOT NULL VARCHAR2(20) DATE_PROC NOT NULL DATE As simple as it might loo...

When to add index on joined tables

I have a mysql table with 9 million records that doesn't have any indices set. I need to join this to another table based on a common ID. I'm going to add an index to this ID, but I also have other fields in the select and where clause. Should I add an index to all of the fields in the where clause? What about the fields in the s...

How to add more than one WHERE statements in MySQL?

Can anyone give me some examples to make query which has more than one WHERE statements please? I have the following query and I want to add WHERE privacy = 'public' $query = $this->db->query("SELECT DATE_FORMAT(eventDate,'%d') AS day,eventContent,eventTitle,id FROM eventcal WHERE eventDate BETWEEN '$current_year/$current_month/01' A...

linq where condition on subselect

how can we add a where condition to a linq subselect query. i.e. List<CallLog> callLog = CallLog.SampleData(); List<Contacts> contacts = Contacts.SampleData(); var q = from call in callLog where call.Incoming == true group call by call.Number into g select new contacts { contact....

More efficient SQL than using "A UNION (B in A)"?

Edit 1 (clarification): Thank you for the answers so far! The response is gratifying. I want to clarify the question a little because based on the answers I think I did not describe one aspect of the problem correctly (and I'm sure that's my fault as I was having a difficult time defining it even for myself). Here's the rub: The result s...

SQL Query JOIN Performance

Hey all, I wanted to know what is better performance-wise: to put the conditions in the JOIN? (x JOIN y on x.hi = y.hi AND ....) or maybe to put it under the WHERE, and leave the JOIN only with the crossing condition. thanks folks ...

How can I re-use WHERE clause logic with DBI?

Hi all: Disclaimer: first time I've used DBI. I have a MySQL table with a lot of indexed fields (f1, f2, f3, etc) that are used to generate WHERE clauses by long-running processes that iterate over chunks of the database performing various cleaning and testing operations. The current version of this code works something like this: s...

C# FindAll VS Where Speed

Anyone know any speed differences between Where and FindAll on List. I know Where is part of IEnumerable and FindAll is part of List, I'm just curious what's faster. ...

SubSonic 3.0 Multiple Where clause with inner joined tables

Hi, everyone. I am getting a error with following code (C# with SubSonic 3) (Korisnik == User && Uloga == Role) dbPupinDB db = new dbPupinDB(); SqlQuery query = db .SelectColumns( KorisnikTable.IdKorisnikColumn, KorisnikTable.UsernameColumn, KorisnikTable.EmailColumn ) ...

NHibernate mapping. Set collection of joined-subclass declared elements and the where property.

I am working on a project where persisted data can be flagged for deletion, but remains in the database having a column (is_deleted) set to TRUE. This works fine using the hibernate class mapping property "where" and adding where="is_deleted = 0" to the tags. But it fails when I declare a set of sub-class elements. This simplified exam...

Selecting from two tables, with different columns, where one needs a count

I have two tables, TableA and TableB. I need to select one count value from TableA, based on a where condition. I need to select two values from TableB. I'd like all the values in one result set. There will never be more than one row in the result set. Here's what I have now: SELECT count(id) FROM TableA WHERE ($some_where_statement)...

[mysql] where query count result > 0

Hi all, I need to do a query like this: SELECT wposts.ID FROM posts wposts WHERE ( SELECT COUNT(ID) FROM surveys WHERE POST_ID = wposts.ID) > 0 but need it to be working ? ...