where-clause

Grouping multiple MySql queries

Hello everyone, I have a simple query as listed below SELECT id, name, email FROM users WHERE group_id = 1 This works great until, I then start adding LIKE queries, chained with OR statements to the end. SELECT id, name, email FROM users WHERE group_id = 1 AND id LIKE $searchterm OR name LIKE $searchterm OR email LIK...

SQL: Dynamic Where Clause using IN statement dying on records with NULL values

I am trying to implement search funtionality for our database through a website. The database has one master table and five tables that are foreign keyed to the master (detail tables). Detail tables hold nullable integer values that are hooked to lookup tables in the application. I want to allow a user to select any/all values from a loo...

MySQL: ERROR 1054 (42S22): Unknown column in 'where clause'

I'm doing some changes on a WordPress database. I need to replace the URLs in the GUID field on the wp-posts table with the URLs coming from another table called ebdurls. The description of the tables is as follows: wp_posts: the field type for the two fields I need are: ID -> bigint(20) unsigned guid -> varchar(255) And the table w...

Two conditions for one field in MySQL WHERE

Hi, Is there a way for me to have two conditions on one field in MySQL Where?... I have a field called type and I want to do this: WHERE `type` != 'name' AND `type` != 'photo' I'm hoping for a better way to do that, so I could compare type to two possible options? Thanks! ...

Linq Where Clause - Accessing a tables column name.

Hello all, I need a bit of inspiration from somewhere and hoping someone, anyone could help. This stems from a previous thread i created whereby I want to be able to do a autocomplete search on a complete data table i.e. all the data from all the columns. I have created a stored procedure that pulls together the autocomplete items and...

SQL Server 2005 where condition with string comparison

I am using SQL Server 2005 with the following query SELECT * FROM EMPLOYEE WHERE EMP_NAME = 'ABCD' It gave me the proper results and when i tried the same query with 'ABCD ', then also it gave me the same result!!! I feel it should not give any results as there is no employee with name 'ABCD ' Or "WHERE" condition works like thi...

SQL Count where clause

I have the the following SQL statement: SELECT [l.LeagueId] AS LeagueId, [l.LeagueName] AS NAME, [lp.PositionId] FROM (Leagues l INNER JOIN Lineups lp ON l.LeagueId = lp.LeagueId) WHERE (lp.PositionId = 1) OR (lp.PositionId = 3) OR (lp.PositionId ...

Trying to understand a SQL where clause

I am hoping someone can help interpret the last code line (@Active=1....) for this SQL clause: SELECT DISTINCT LOC_ID ,LOC_CODE ,ADDR_LINE_1 ,ADDR_LINE_2 ,ADDR_LINE_3 ,CITY ,STATE ,COUNTRY ,POSTAL_CODE ,COMPANY ,OPERATION_TYPE ,PROCESS ,ADDR_LINE_1 + ',' +ADDR_LINE_2+ ',' + CITY + '-' ...

Using Array.BinarySearch() to return first value <= lookup value ?

I'm trying to create a "lookup" column that would return the index of the array value that is equal to or less than the value being looked up. So this is my attempt, which seems to work fine, but I was wondering if there is a cleaner way of doing it ? // Sorted float[] ranges = new float[] { 0.8f, 1.1f, 2.7f, 3.9f,...

using generated column in a MySQL where clause

If I have a query, such as: select column1, ( select count(*) from table2 ) as some_count from table1 where column1 = 'foo' I can use column1 in the where clause, but if I try to add and some_count > 0 then I get an error that some_count doesn't exist. How can I use that in a where clause? ...

Left Join with where clause

I have 3 tables A, B and C I am doing this :- /* There is no relation between Table A and Table B . Table A is just used to provide values to C.Profile */ 1st step ) D <---- Select * from C where Profile=1 // want to give a specific ProID(I have successfully retrieved it from A table) 2nd Step ) Output <--- Select B.sname,D.Status fr...

Multiple row SQL Where clause

This is probably a simple SQL statement, but it's been a while since I've done SQL and I'm having issues with it. I have this table design: ID PositionId Qty LeagueId 1 1 1 5 2 3 2 5 3 8 5 2 4 1 6 4 What I need to get are all...

Dynamic LINQ Multiple Where Clause

Hello all. Still really struggling with this and appear to be going round in circles. I have the following code that is driving me nuts. It should populate a list of items to be used in an autocomplete text box: public string[] GetAutoComplete(string prefixText, int count) { string memberid = HttpContext.Current.Sessio...

Propel: negate multiple conditions

I need to negate multiple conditions at once using Propel. E. g. a corresponding sql condition is: WHERE !(something = 'a' and someOtherThing = 'b') I couldn't find a way to solve this using Propel ORM. Is there a way to build this query with the Criteria-API that Propel 1.3 provides? ...

Create a new column in data.frame using conditions of each row

I have an R data frame: > tab1 pat t conc 1 P1 0 788 2 P1 5 720 3 P1 10 655 4 P2 0 644 5 P2 5 589 6 P2 10 544 I am trying to create a new column for conc as a percentage of conc at t=0 for each patient. As well as many other things, I have tried: tab1$conct0 <- tab1$conc / tab1$conc[tab1$t == 0 & tab1$pat == tab1...

LINQ Join Where Clause

Hello all. I'm struggling with a join/where clause with what is a rather simple sql select statement. I am trying to retrieve a list of product information from tb1 with the where condition behind situated in tbl2 but this must be joined by three different columns. so the SQL would look something along the lines of: SELECT tb1.* ...

C# Generics: Inserting T as the where T : IComparable<T> interface conflict

This is a challenge for the C# generics / design patterns masters. I'm trying to implement a generic heap, and then a priority queue that uses the heap. My heap's signature is: class Heap<TKey, TValue> where TKey : IComparable<TKey> My priority queue class is: public delegate IComparable<T> Evaluator<T>(T item); class PriorityQueu...

Linq Subquery Where Clause

I need some help with thsi linq query. It shoudl be fairly simple, but it is kicking my butt. I need to use a subquery to filter out data from the main query, but every path I have tried to use results in failure. The subquery by itself looks like this. int pk = (from c in context.PtApprovedCertifications where c.FkosParticip...

Mysql query help with where clause

Community Service Table |student name (id in real table)|hours|year|event name (id in real table)| |Johnny Smith | 5|2010|Beach Clean-up | |Samantha Bee | 3|2011|Daily Show Volunteering | |Samantha Bee | 2|2011|Daily Show Bake Sale | |Bilbo Baggins...

SQL: Whats the difference between ... WHERE O.type = N'U' ... and ... WHERE O.type = 'U' ...

Today I came across an SQL statement that contains an element I've never seen. Maybe someone can elaborate? This SQL is from a stored procedure in Sybase ASE 15 SELECT O.id, OWNER = U.name, O.name, O.type FROM xxx.dbo.sysobjects O LEFT JOIN xxx.dbo.sysusers U ON O.uid = U.uid WHERE (O.type = N'U' OR O.type = N'S' OR O....