where-clause

Need to simplify [duplicate]

*爱你&永不变心* 提交于 2019-12-14 03:28:45
问题 This question already has an answer here : Need better current datetime syntax (1 answer) Closed 5 years ago . WHERE (((tblNewCaseLog.CasePersonAddress) Like "*" & GetCriteria() & "*") AND ((DatePart("yyyy", [DateLog])) Between DatePart("yyyy",Now())-1 And DatePart("yyyy",Now()))) ORDER BY tblNewCaseLog.DateLog DESC; --Really need to improve old Access syntax to SQL 2008 for migration. Gracias! 回答1: WHERE tblNewCaseLog.CasePersonAddress Like '%' + @GetCriteria + '%' AND YEAR([DateLog])

ACCESS 2010 SQL— using WHERE IN on SELECT TOP subquery field

妖精的绣舞 提交于 2019-12-14 01:26:00
问题 I want this query to tell me the spending in 2012 of the companies who were the top 10 spenders in 2013! SELECT [Company], Sum([SPENDING]) FROM [Data] WHERE [Company] IN ( SELECT TOP 10 [Company] FROM [Data] WHERE [Year] IN ("2013") GROUP BY Company ORDER BY Sum([SPENDING]) DESC ) AND [Year] IN ("2012") GROUP BY Company ; When I try to run it, I get no errors, but Access says it is "running query" and never finishes. The size of the data is not the problem. This is the closest example I found

MySQL strange behaviour for comaprison operator (!=/<>) i.e. NotEqualTo

微笑、不失礼 提交于 2019-12-13 19:40:44
问题 I am using simple WHERE clause to fetch records from a table using NotEqualTo comparison. Ironically it doesn't return recrods where column has no value at all . Query SELECT * FROM TABLE WHERE COL<>'Something' Above query will return all records where COL isNotEqual to Something, however, It doesn't return those where COL is empty or NULL . Why is that so? It should return records where COL is empty/null as it still satisfies the condition that it isn't equal to 'Something' 回答1: Okies thanks

SQL Replace last 2 chars if last 2 chars matches

淺唱寂寞╮ 提交于 2019-12-13 18:43:33
问题 I hope someone can help me. I have a column with 160.000 rows. A lot of those column values (permalinks) end with "-2" which is unneccesary so I want to remove them. But I can't get it to work. I tried it with the following query: UPDATE wp_pods_cars SET permalink = Replace(permalink,'-2','') WHERE RIGHT( 'permalink' , 2 ) = '-2'; This query seems to be valid but the RIGHT() seems to make troubles. Probably it can just be used for a SELECT and not in a WHERE-clause. I was thinking about Regex

Multiple row SQL Where clause

夙愿已清 提交于 2019-12-13 16:54:46
问题 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 the rows that have specific PositionId's and Qty's. Something like: SELECT ID, PositionId, LeagueId, Qty FROM Lineups WHERE (PositionId = 1 AND Qty = 1) AND (PositionId = 3 AND Qty = 2) What I'm trying to get is LeagueId 5 returned since it has both PositionId of 1 and

Use array of strings for comparing in Where-Object in PowerShell

梦想与她 提交于 2019-12-13 11:11:07
问题 I have a user list of Active Directory that I retrieve this way: $users = Get-AdUser -Filter {(Enabled -eq "True" )} -Properties Description The problem is that I have a specific set of users that is based in their description: Admins Secretaries Mail men What I do is create sublists like this: $Admins = $users | Where-Object Description -eq 'Administrator' The problem however is, that there is no standardization. The person who creates an user can write 'Admin' or 'Administrator' or 'adm',..

How to get total number of rows within subquery for multiple conditions

对着背影说爱祢 提交于 2019-12-13 07:11:50
问题 This query return number of rows where Sum of Product's Quantity is equal to 0 and Product Name is 'XYZ'. But I want same result for each products. For example if I remove product name from where clause so it will bring SUM of every product where quantity is 0. I want it to return separately for each products. Products may increase in future. I have to first check how many distinct products are there in CustomerProduct table and then need to query same things for each product. How can I do

How to modify Mongo values in where-clause in query?

我们两清 提交于 2019-12-13 03:14:27
问题 Is there any way to modify the mongo values in a where-clause in a find query? This is the one I use right now: $db->users->findOne(array("redirect_uri" => $arrParsedUrl['host'])); In this case I need to make sure that the value earlier inserted into the database is only the host part of the URL. What I would like to do is someting like this (but it's not working): $db->users->findOne(array(parse_url("redirect_uri")['host'] => $arrParsedUrl['host'])); In this case I would be able to insert

mysql multiple and condition's

混江龙づ霸主 提交于 2019-12-13 02:55:33
问题 I need to know how to query a mysql database based on multiple and conditions... im trying to find all male users online above age 18. php code : $sql = mysql_query("Select * FROM `users` where `round`= '".$userData["round"]."', `sex` = 'm', `age` = '18', `online_stas` = 'online' ")or die(mysql_error()); 回答1: Reading responses and the fact that you still have errors, I come to think the posibility of having "M" instead of "m" in sex field. You can try: $sql = mysql_query("SELECT * FROM `users

CREATE VIEW WHERE SELECTid = VIEWrowID

泪湿孤枕 提交于 2019-12-13 01:33:36
问题 Warning: vagueness & unclear questioning will abound because I know squat about databases. I just discovered that I need to use views as surrogates for a cronned update statement. I can somewhat get the view to work, but I'm having trouble with rows. This post helped me to bang out the update I need, but now that I know that views can run that update whenever it's needed rather than on a cron schedule, how can I set the view's column value based upon the view's row id or equivalent? I've got