where

Select current week using LINQ

ⅰ亾dé卋堺 提交于 2020-01-14 08:37:33
问题 How do I write the where statement that select records with Date field between Sunday to Saturday of a given date. Data Fields: Id, Name, Date 回答1: Where date is the date in question, how about: DateTime start = date.Date.AddDays(-(int)date.DayOfWeek), // prev sunday 00:00 end = start.AddDays(7); // next sunday 00:00 var qry = from record in data where record.Date >= start // include start && record.Date < end // exclude end select record; 回答2: DateTime givenDate = DateTime.Today; DateTime

Difference between IS NULL criteria in JOIN and WHERE in a query

冷暖自知 提交于 2020-01-11 06:43:11
问题 create table #t1 (id int) create table #t2 (id int) insert into #t1 values (1) insert into #t1 values (2) insert into #t1 values (3) insert into #t2 values (1) insert into #t2 values (2) I ran the below queries, and I get 2 different outputs. Second is the desired output. I cannot understand the reason for output given by query1. Please assist me to understand the result. -- Query1 select * from #t1 a left join #t2 b on a.id = b.id and b.id is null -- Query2 select * from #t1 a left join #t2

Can the “IN” operator use LIKE-wildcards (%) in Oracle?

谁都会走 提交于 2020-01-09 07:20:30
问题 I have searched this question, and found an answer in MySQL but this is one of those incidents where the statement fails to cross over into Oracle. Can I use wildcards in "IN" MySQL statement? pretty much sums up my question and what I would like to do, but in Oracle I would like to find the legal equivalent of Select * from myTable m where m.status not in ('Done%', 'Finished except%', 'In Progress%') Thanks for any help 回答1: Select * from myTable m where m.status not like 'Done%' and m

Insert value into specific column from another table with groupby

强颜欢笑 提交于 2020-01-07 06:55:14
问题 I am using MySQL. I want to insert value's result from groupby of datetime to specific column (using where, maybe). Let say: I have two tables (a, b). In table a, I want to get how many total records during a hour (which I have datetime column), then the result will insert into table b, but in specific ID (there is already exist ID's value). This is my error code: INSERT INTO b(value) WHERE ID=15 SELECT DAY COUNT(*) FROM a WHERE date >= '2015-09-19 00:00:00' AND date < '2015-09-19 00:59:59'

Query that Counts records with a WHERE clause

戏子无情 提交于 2020-01-06 15:31:26
问题 SELECT EmailOfConsumer, COUNT(EmailOfConsumer) as 'NumberOfOrders', SUM(CAST(Total as money)) as 'TotalValue', (SUM(CAST(Total as money))/COUNT(EmailOfConsumer)) as 'AverageValue' FROM webshop GROUP BY EmailOfConsumer ORDER BY TotalValue DESC This brings back: EmailOfConsumer NumberOfOrders TotalValue AverageValue test 1 2000000000.10 2000000000.10 I would like to add a search on WHERE NumberOfOrders = '1' I have tried adding WHERE COUNT(EmailOfConsumer) = '1' but I get this error: An

MVC Where condition with search function

烈酒焚心 提交于 2020-01-06 12:57:08
问题 I am trying to make search function with actionLink. the actionLink will give parameter to controller such as @Html.ActionLink("Intel Core i5", "Search", "Store", new { @searchString = "i5" }, null) I pass this value and it is working in controller. However, when I trying to compare decimal datatype, not string datatype. Currently, processor is varchar, and dissplaySize is decimal. I don't know how to handle displaySize with searchString. My controller is this. //Controller here public

MVC Where condition with search function

自闭症网瘾萝莉.ら 提交于 2020-01-06 12:55:08
问题 I am trying to make search function with actionLink. the actionLink will give parameter to controller such as @Html.ActionLink("Intel Core i5", "Search", "Store", new { @searchString = "i5" }, null) I pass this value and it is working in controller. However, when I trying to compare decimal datatype, not string datatype. Currently, processor is varchar, and dissplaySize is decimal. I don't know how to handle displaySize with searchString. My controller is this. //Controller here public

MVC Where condition with search function

只愿长相守 提交于 2020-01-06 12:55:04
问题 I am trying to make search function with actionLink. the actionLink will give parameter to controller such as @Html.ActionLink("Intel Core i5", "Search", "Store", new { @searchString = "i5" }, null) I pass this value and it is working in controller. However, when I trying to compare decimal datatype, not string datatype. Currently, processor is varchar, and dissplaySize is decimal. I don't know how to handle displaySize with searchString. My controller is this. //Controller here public

Laravel set an Automatic WHERE Clause

痞子三分冷 提交于 2020-01-06 08:16:12
问题 I use models that extend a generic_model, which in turn extends Eloquent (so that I have several crud methods I use already set to be inherited). A lot of the tables I use invoke soft delete, which needs a WHERE clause of... WHERE deleted = 0 Is there a way to make Laravel behave in such a way that this WHERE clause is automatically included in all queries and all queries to objects that are related to one another? e.g. pages where id = 5 and deleted = 0 and then... images where page_id = 5

Laravel 5.6 withCount and where statement

好久不见. 提交于 2020-01-04 09:39:15
问题 I'm using laravel 5.6. I have 3 tables : players, games and game_player table. Retrieving the game count of every player is easy with this in the index action of the PlayersController: //Get game count of every player $players = Player::withCount('games')->get(); Is there a way to retrieve the game count for the games when the player has won the game? (in the index action of the playerscontroller) I'm not sure how to do this. Can someone help? games table migration $table->integer('winner')-