where

Dynamic where clause in sqlahcmey

Hello I am trying to make the where clause in sqlalchemy for where condition like a==b and id in(1,2,3,4,5) and (x==y or t==y) i get input as [['a==b'], 'and', [<object of sqlalchemmy binary expression>], 'and', '(', ['x==y'], 'or', ['t==y'], ')'] Now from this list input i want to make the where expression. I tried making all...

How to write the Where clause in my ObjectQuery?

Please see my code: var miportal = new AdventureWorksEntities(); // one to many relationship var result = miportal.AddressType .Include("CustomerAddress") .Where(at => at.CustomerAddress.Any(ca => ca.CustomerID == 3)); there are 2 tables; AddressType and CustomerAddress (1 CustomerAddress has...

Maintain WHERE Order In SQL Select

Is it possible to maintain the order of the WHERE clause when doing a SELECT for specific records? For instance, given the following SELECT statement: SELECT [RecSeq] FROM [MyData] WHERE [RecSeq]=3 OR [RecSeq]=2 OR [RecSeq]=1 OR [RecSeq]=21 OR [RecSeq]=20 OR [RecSeq]=19 OR [RecSeq]=110 OR [RecSeq]=109 OR [RecSeq]=108 OR [RecSeq]=53 O...

Can I restrict generic method to more than one interface?

Hello, I have a generic method public static void DoSomething<T>() {...} . Now I want to restrict that T. public static void DoSomething<T>() where T: IInterface1 {...} But what I really want is allowing multiple interfaces, something like public static void DoSomething<T>() where T: IInterface1, IInterface2 {...} But that does...

MySQL where clause and ordering by avg() as a sub query

Although I can group and order by on an aliased sub query, I can't use the alias in a where clause. Do I need to use a join instead? Works: SELECT entries.*, (SELECT avg(value) FROM `ratings` WHERE ratings.entry_id = entries.id) as avg_rating FROM `entries` ORDER BY avg_rating DESC Fails ("unknown column 'avg_rating' i...

Linq: What is the difference between Select and Where

In linq there is the Select and Where methods. What should every developer know about these two methods (Example: when to use one over the other, any advantages over the other, etc) ...

What is the purpose of using WHERE 1=1 in SQL statements?

Possible Duplicates: Why would a sql query have where 1 = 1 Why would someone use WHERE 1=1 AND <conditions> in a SQL clause? I've seen that a lot in different query examples and it goes to probably all SQL engines. If there is a query that has no conditions defined people (and specially ORM frameworks) often add always-true ...

iPhone dev - create array in init or viewDidLoad

In my UIViewController subclass should I initialize the NSArray of data for the UIPickerView in init or in viewDidLoad and why? Thanks. ...

Generics in Boo - Is there an equivalent of the C# where clause

Is there a way in Boo to express some constaints on generic types as we can do using the where clause in C#? In short, how to write?: class MyClass<T> where T:Icomparable<T> {...} Thank you ...

Determine Which Part(s) of WHERE Statement Failed

Let's say I have a SQL statement like this that checks a user login: SELECT * FROM users WHERE username='[email protected]', password='abc123', expire_date>=NOW(); Is there a way in SQL to determine specifically which WHERE conditions fail, without having to separate each condition into its own query and test individually? In this sp...

SQL - WHERE clause on each SET command in UPDATE?

Hi, I'm trying to create an SQL query in PHP to update a table. Is it possible to have a different WHERE clause for each affected row? eg something like: UPDATE table SET val=X WHERE someproperty = 1, SET val=Y WHERE someproperty = 2 etc? Any help appreciated. Thanks ...

php and mysql. WHERE date <= X Hours ago?

I was wondering what is the best way to write the where statement in PHP where targetDate < Date.Now - HardCodedHours in PHP ...

Bitwise operators LinqDataSource Where

Hi, I have a byte column called 'Type' in my MS Server database. On my Asp.net page I have a ListView and a LinqDataSource. The 'Type' column is different enum flags. I would like to check specific bits in column 'Type' in my LinqDataSource Where property. I tried with: (Check first bit) Type == (Type | 1) Type = (Type | 1) Type | 1 ...

How to grab items from a DB by date

This is my script: $spending_period = time() - (30 * 24 * 60 * 60); $spending_period = date('Y-m-d', $spending_period); $monthly_income_query="SELECT amount FROM budget_items WHERE (date_code >= '$spending_period') && (type=='Income') ORDER BY date_code DESC"; $monthly_income_result=mysql_query($monthly_income_query); while($monthly_inc...

C# generic "where constraint" with "any generic type" definition?

Let me give example: I have some generic class/interface definition: interface IGenericCar< T > {...} I have another class/interface that I want to relate with class above, for example: interface IGarrage< TCar > : where TCar: IGenericCar< (any type here) > {...} Basically, I want my generic IGarrage to be dependent on IGenericCar,...

LINQ: multiple Where calls only uses last one???

I'm trying to get a query going that will search multiple tags. The tags are db based and I've related them to the entity with a junction table. If I search with 1 tag, I get the correct results, but if I search with 2 tags, I only get the entities that match the second tag. Here's the C# code that builds the IQueryable: var awTable ...

PHP/MYSQL: SELECT statement, multiple WHERE's, populated from database

I'm trying to figure out how to get a select statement to be populated by an ever-changing number of where's. This is for an order-status tracking application. Basically, the idea is a user (customer of our company) logs in, and can see his/her orders, check status, etc. No problem. The problem arises when that user needs to be associat...

Oracle date function

Hi, I am executing the below query,It returns me the blank row.However there are records in the table having upd_time = '12-MAR-08'.I don't understand why it is not returning the date '12-MAR-08'.Please help me out?? SELECT br_data.upd_time FROM BANKREC.br_data where br_data.upd_time = '12-MAR-08'; ...

SQL Not Like Statement not working

I have the following code within a stored procedure. WHERE WPP.ACCEPTED = 1 AND WPI.EMAIL LIKE '%@MATH.UCLA.EDU%' AND (WPP.SPEAKER = 0 OR WPP.SPEAKER IS NULL) AND WPP.COMMENT NOT LIKE '%CORE%' AND WPP.PROGRAMCODE = 'cmaws3' The NOT LIKE statement is not working, and yes before anyone says anything there are items with the COMMEN...

[Java] Generics and "where" clause

In. NET, I can do something like this: public static T[] CreateAndFillArray<T>(int size) where T : new() { T[] array = new T[size]; for (int i = size - 1; i >= 0; i--) array[i] = new T(); return array; } We must to specify "where T : new()" clause. How to do it in Java? ...