where-clause

False value in Where Clause Returns All Rows?

≯℡__Kan透↙ 提交于 2019-12-23 09:27:30
问题 I have a query that looks like this: `SELECT id, username FROM table_name WHERE username=0` When I run this query MySQL returns all rows in table_name. Additionally, if I substitute 0 for false I get the same results. If I use null or an empty string then I get no rows returned (as expected). The username column is varchar(50) if it makes a difference. My question then is this : Why does putting 0 or false in that query return all rows in the table? Is this a MySQL setting? This worries me a

MySQL UPDATE WHERE IN for each listed value separately?

非 Y 不嫁゛ 提交于 2019-12-23 04:21:12
问题 I've got the following type of SQL: UPDATE photo AS f LEFT JOIN car AS c ON f.car_id=c.car_id SET f.photo_status=1 , c.photo_count=c.photo_count+1 WHERE f.photo_id IN ($ids) Basically, two tables ( car & photo ) are related. The list in $ids contains unique photo ids, such as (34, 87, 98, 12). With the query, I'm setting the status of each photo in that list to "1" in the photo table and simultaneously incrementing the photo count in the car table for the car at hand. It works but there's one

What is the best way to dynamically add to a where clause in a nhibernate query in C#?

↘锁芯ラ 提交于 2019-12-23 04:12:33
问题 I have a some C# code that is querying a database using nhibernate that looks like this: public void Query() { IEnumerable<Project> list = session.Query<Project>() .Where(p => !p.IsDeleted) .FetchMany(r => r.UnfilteredProjectApplications) .ThenFetch(r => r.Application) .ToList() } I now have a number of user driver filters so, based on the parameters passed in, i want to add to the where clause. So something like this: public void Query(string name) { if (!String.IsNullOrEmpty(name) {

Mysql - how to use like on multiple columns

久未见 提交于 2019-12-23 02:42:23
问题 I've searched in mysql query a word in multiple column in java program. The number of column is variable. It is correct this query: select * from customer with (city, name) like%'adelaide'% 回答1: You can use CONCAT() function: select * from customer WHERE concat(city,name) like '%adelaide%' You can add as many columns to the concat function as you like. Also as you see I changed your like syntax, '%WORD%' and used a simple where clause. 回答2: It's better to use CONCAT_WS() function. CONCAT()

Jquery query XML document where clause

北战南征 提交于 2019-12-23 02:07:34
问题 I have an XML document that I want to search a specific date and get information for just that date. My XML looks like this: <month id="01"> <day id="1"> <eitem type="dayinfo"> <caption> <text lang="cy">f. 3 r.</text> <text lang="en">f. 3 r.</text> </caption> <ref href="link" id="3"/> <thumb href="link" id="3"/> </eitem> </day> <day id="7"> <eitem type="dayinfo"> <caption> <text lang="cy">f. 5 v.</text> <text lang="en">f. 5 v.</text> </caption> <ref href="link" id="4"/> <thumb href="link" id=

Converting conditionally built SQL where-clause into LINQ

落花浮王杯 提交于 2019-12-22 17:55:40
问题 So I didn't see a question here that really answers this question. It's kinda a newbie question about linq but I would like to know if it would be possible to convert the following sql query (built using C#) into a linq query: public void DoSomeQuery(bool whereCriteria1, bool whereCriteria2) { string sqlQuery = "SELECT p.*"; string fromClause = " FROM person p"; string whereClause = " WHERE "; if (whereCriteria1) { fromClause += ", address a"; whereClause += " p.addressid = a.addressid and a

Building dynamic where clause, Linq To Sql

泄露秘密 提交于 2019-12-22 11:17:18
问题 I am using EF Code first 4.2, What sort of solution do you propose when the where clause needs to be dynamically built? Yet Include functionality would be highly required: var results = db.Set<dynamicType>.Where("dynamic conditions").Include("...."); The dynamic condition above needs to lookup to another table to filter the records: If I wanted to write that in Linq expression it would be something like: var result = db.Set<Contact>().Where(c=>c.AccountId == _Id_param || db.Set<LinkTable>()

How to perform bitwise operations arithmetic in MS-ACCESS

只谈情不闲聊 提交于 2019-12-22 09:49:42
问题 Inside MSACCESS I want to use relatively simple bitwise operations in WHERE clause of queries such as this: SELECT * FROM Table1 WHERE Column1 (some operator) 8 = 0 This would: Return rows where Column1 does not have its 4th bit set e.g. 0, 1, 2, ..., 7 (all have their 4th bit clear) and 16 (it is 00010000b) Exclude rows where Column1 is 8, 9, 10, ..., 15 etc. PS: are bitwise operators different from boolean operations? 回答1: If you can run your query in in ANSI-92 Query Mode (e.g. by changing

How do I handle nulls in NOT IN and NOT LIKE statements in Oracle?

北城余情 提交于 2019-12-22 09:07:13
问题 I have a long piece of PL/SQL which is working well except for one small part of the where clause. I'm expecting that one row should be returned but, because the fields the where clause checks are null, the row is not being returned despite meeting the criteria. I read a very good note here : http://jonathanlewis.wordpress.com/2007/02/25/not-in/ It explains how Nulls affect NOT IN statements and I presume it's the same for NOT LIKE as well. What I haven't been able to find is the comparable

MySQL update query with WHERE clause and INNER JOIN not working

那年仲夏 提交于 2019-12-22 08:17:12
问题 Can't seem to reach the next step in my update query. I'm able to successfully view columns related to the select no problem: SELECT sales_flat_order_grid.entity_id,sales_flat_order_grid.increment_id,sales_flat_order.coupon_code FROM sales_flat_order_grid INNER JOIN sales_flat_order ON sales_flat_order_grid.entity_id = sales_flat_order.entity_id WHERE sales_flat_order_grid.increment_id = "12345678"; This shows 3 columns all where related to the correct increment_id. The next step is to update