where-clause

SQLite query where clause with floating point numbers fails?

不想你离开。 提交于 2019-12-01 06:44:15
I'm putting a float in an Android based SQLite database, like so: private static final String DATABASE_CREATE = "create table " + DATABASE_TABLE + " (" + KEY_ID + " integer primary key autoincrement, " + KEY_FLOAT + " REAL, " + ... ... content.put(KEY_FLOAT, 37.3f); db.insert(DATABASE_TABLE, null, content); When I query the table: Cursor cursor = db.query(false, DATABASE_TABLE, new String[] { KEY_ID, KEY_FLOAT, ... }, KEY_LATITUDE + "=37.3", null, null, null, null, null); the cursor comes back empty. If I change the value of the float to 37.0 it works properly, returning the record in the

can MySQL temporary variables be used in WHERE clause?

可紊 提交于 2019-12-01 06:24:05
In MySQL, can temporary variables be used in the WHERE clause? For example, in the following query: SELECT `id`, @var := `id` * 2 FROM `user` @var is successfully set to twice the value of `id` However, if I try to filter the result set to only include results where @var is less than 10: SELECT `id`, @var := `id` * 2 FROM `user` WHERE @var < 10 then I get no results. How can I filter the results based on the value of @var? You need to assign an alias, and test it in the HAVING clause: SELECT id, @var := id * 2 AS id_times_2 FROM user HAVING id_times_2 < 10 Note that if you're just using the

how to pass a variable in WHERE IN clause of oracle sql?

倖福魔咒の 提交于 2019-12-01 05:21:05
Hi I have a variable $1 which hold comma separated email addresses like john@example.com,pat@example.com . I wish to pass this variable in a where clause like where myColumn in ($1) But obviously this won't work, I tried APEX_UTIL.STRING_TO_TABLE and DBMS_UTILITY.COMMA_TO_TABLE but in vain. Any help appreciated. As Pavanred alluded to, the easiest way -- though not necessarily the best -- is to interpolate the values yourself. You don't say what your calling language is, but something like: sql = "SELECT something FROM whatever WHERE myColumn in (" + $1 + ")" However, this means it's very

Cassandra: Query with where clause containing greather- or lesser-than (< and >)

断了今生、忘了曾经 提交于 2019-12-01 04:50:32
I'm using Cassandra 1.1.2 I'm trying to convert a RDBMS application to Cassandra. In my RDBMS application I have following table called table1: | Col1 | Col2 | Col3 | Col4 | Col1: String (primary key) Col2: String (primary key) Col3: Bigint (index) Col4: Bigint This table counts over 200 million records. Mostly used query is something like: Select * from table where col3 < 100 and col3 > 50; In Cassandra I used following statement to create the table: create table table1 (primary_key varchar, col1 varchar, col2 varchar, col3 bigint, col4 bigint, primary key (primary_key)); create index on

can MySQL temporary variables be used in WHERE clause?

放肆的年华 提交于 2019-12-01 04:21:51
问题 In MySQL, can temporary variables be used in the WHERE clause? For example, in the following query: SELECT `id`, @var := `id` * 2 FROM `user` @var is successfully set to twice the value of `id` However, if I try to filter the result set to only include results where @var is less than 10: SELECT `id`, @var := `id` * 2 FROM `user` WHERE @var < 10 then I get no results. How can I filter the results based on the value of @var? 回答1: You need to assign an alias, and test it in the HAVING clause:

how to pass a variable in WHERE IN clause of oracle sql?

孤人 提交于 2019-12-01 04:15:00
问题 Hi I have a variable $1 which hold comma separated email addresses like john@example.com,pat@example.com . I wish to pass this variable in a where clause like where myColumn in ($1) But obviously this won't work, I tried APEX_UTIL.STRING_TO_TABLE and DBMS_UTILITY.COMMA_TO_TABLE but in vain. Any help appreciated. 回答1: As Pavanred alluded to, the easiest way -- though not necessarily the best -- is to interpolate the values yourself. You don't say what your calling language is, but something

Dynamic Where Clause over relational tables with LINQ to SQL

本小妞迷上赌 提交于 2019-11-30 20:51:10
I need help for a dynamic where clause over relational tables (one to many) in LinqToSql. User select conditions from page. (there is 4 input that user select the clauses) For example CompanyName and CompanyTitle from Customer table and OrderDate and ShipCity From Order table. But user can select one ore many of them from page interface and dynamic query will be generated at codebehind and select From LinqToSql. You can give similar type of example from another web pages. Are you looking for something like this, where you define the "base" query, and then evaluate parameters to determine if a

MYSQL Select rows where date is older than datetime

我怕爱的太早我们不能终老 提交于 2019-11-30 17:51:50
I am coding a status item for a website and need to load statuses older than a variable that contains a datetime. So the database has a field called added date which is a datetime field and I have a string in datetime format and i want to select all rows older than my datetime format string. How would this be structured in MYSQL? Thanks in advance. select status_column from your_table where added_date < '2012-05-12' mysql DATETIME type is used for values that contain both date and time parts. Try this SELECT datecolumn FROM table WHERE datetime_date > '2012-05-12 01-32-56' try this $today =

Linq include with where clause

久未见 提交于 2019-11-30 17:21:42
问题 Hey so I've got the situation where I'm pulling a client back from the database and including all the case studies with it by way of an include return (from c in db.Clients.Include("CaseStudies") where c.Id == clientId select c).First(); but what I want to do now is and a where clause on the included casestudies so that it only returns the case studies where deleted = false sort of like this return (from c in db.Clients.Include("CaseStudies") where c.Id == clientId && c.CaseStudy.Deleted ==

Swift “where” Array Extensions

孤街醉人 提交于 2019-11-30 17:01:15
As of Swift 2.0 it seems we can get closer to extensions of generic types applicable to predicated situations. Although we still can't do this: protocol Idable { var id : String { get } } extension Array where T : Idable { ... } ...we can now do this: extension Array { func filterWithId<T where T : Idable>(id : String) -> [T] { ... } } ...and Swift grammatically accepts it. However, for the life of me I cannot figure out how to make the compiler happy when I fill in the contents of the example function. Suppose I were to be as explicit as possible: extension Array { func filterWithId<T where T