where-clause

Oracle performance using functions in where clause

时光毁灭记忆、已成空白 提交于 2019-12-10 17:17:21
问题 In a stored procedure (which has a date parameter named 'paramDate' ) I have a query like this one select id, name from customer where period_aded = to_char(paramDate,'mm/yyyy') will Oracle convert paramDate to string for each row? I was sure that Oracle wouldn't but I was told that Oracle will. In fact I thought that if the parameter of the function was constraint (not got a fierld nor a calculated value inside the query) the result should be allways the same, and that's why Oracle should

“IN” condition at CASE WHEN on WHERE CLAUSE?

回眸只為那壹抹淺笑 提交于 2019-12-10 16:29:05
问题 I have an complex situation. I want to write an sql query including "case when" condition on "where clause". Just like that: SELECT * FROM <table> WHERE <Column1> in CASE <Column2> WHEN 1 THEN ('OP', 'CL') WHEN 0 THEN ('RE', 'ST') END Column1 must be "in", not "=". Because there is multiple value at condition for Column1. That query returns "Incorrect syntax near ','." error. Can you give me any suggestion? (Sorry for my bad English.) EDIT : I think I misunderstood. If Column2 is 1, condition

Dynamic Expressions in “Where” Clause - Linq to SQL

北城余情 提交于 2019-12-10 16:07:24
问题 I'm new in LINQ so I hope this isn't a stupid question: I have a table with a lot of content presented in a datagrid, and I want the user to be able to filter the grid by using some combo boxes above the grid [like a search bar] I created a method that takes the text in the combo boxes, and placing it the "Where" clause: public void find() { string disName; string statusName; disName = RMcmbDis.Text; //This Get the first string to filter statusName = RMcmbStatus.Text; // this get the second

SQL query where clause [closed]

倖福魔咒の 提交于 2019-12-10 14:57:06
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I have this line in my sql query: WHERE client = $id AND (isinvoiced = 0) OR (isinvoiced = 1 and isrecurring = 1) which gets more results than I am expecting. However, if I write it like this: WHERE client = $id

SQL Count where clause

試著忘記壹切 提交于 2019-12-10 14:32:42
问题 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 = 2) What I really need is to get the rows where the count of the position is greater than a number. Something like: SELECT [l.LeagueId] AS LeagueId, [l.LeagueName] AS NAME, [lp.PositionId] FROM (Leagues l INNER JOIN Lineups lp ON l.LeagueId = lp

Oracle sql MERGE INTO with a single where clause

我是研究僧i 提交于 2019-12-10 11:23:32
问题 I have the following SQL code (this is how much I've got so far): MERGE INTO SCHEMA1.TABLE_1 table1 USING ( SELECT DISTINCT table2.column1, view1.column2 FROM SCHEMA2.TABLE_2 table2 LEFT JOIN SCHEMA2.VIEW_1 view1 ON table2.column2 = view1.column3 ) t2 ON (table1.column3 = t2.column1 ) WHEN MATCHED THEN UPDATE SET table1.column4 = t2.column2; The following is the definition of VIEW_1 : CREATE VIEW SCHEMA_2.VIEW_1 AS (SELECT SCHEMA_2.TABLE_1.COLUMN_1, SCHEMA_2.TABLE_2.COLUMN_1, SCHEMA_2.TABLE_2

PHP PDO: Array in Update SQL WHERE IN () clause

时间秒杀一切 提交于 2019-12-10 11:00:57
问题 I'm trying to take an array of ID numbers and update every row with that ID number. PHP PDO code follows: private function markAsDelivered($ids) { $update = $this->dbh->prepare(" UPDATE notifications SET notified = 1 WHERE notification_id IN ( :ids ) "); $ids = join(',', $ids); Logger::log("Marking the following as delivered: " . $ids, $this->dbh); $update->bindParam(":ids", $ids, PDO::PARAM_STR); $update->execute(); } However, when this is run, only the first item in the list is getting

Mysql Where … In … AND where … in … should only match on same index

梦想与她 提交于 2019-12-10 04:10:42
问题 I have the query: SELECT * FROM `users` WHERE (`firstname` LIKE 'Luke' AND `lastname` LIKE 'Skywalker') OR (`firstname` LIKE 'Foo' AND `lastname` LIKE 'Bar') OR (`firstname` LIKE 'Tom' AND `lastname` LIKE 'Turner'); But i would like to make it a bit more readable by using a where ... in ... I tried SELECT * FROM users WHERE `firstname` IN ('Luke','Foo','Tom') AND `lastname` IN ('Skywalker','Bar','Turner'); But unfortunately this will also match "Tom Skywalker" , "Foo Turner" and all mixes you

Cassandra - WHERE clause with non primary key disadvantages

孤街醉人 提交于 2019-12-10 02:27:59
问题 I am new to cassandra and I am using it for analytics tasks (good indexing needed ). I read in this post (and others): cassandra, select via a non primary key that I can't query my DB with a non-primary key columns with WHERE clause . To do so, it seems that there is 3 possibilities (ALL with major disadvantages): Create a secondary index (not recommended for performance issues). Create a new table (I don't want redundant data even if it's ok with cassandra). Put the column I want to query by

Use a calculated column in a where clause

不打扰是莪最后的温柔 提交于 2019-12-10 00:59:00
问题 I'm trying to use a calculated column in a where clause. I've trying everything from CROSS APPLY, to sub-query select but it does not give me the anything near what I need. My query so far: SELECT p.Code, c.AccountNumber, Sales = (SUM(p.UnitPrice) * SUM(od.QtyShipped)) FROM [dbo].Customer c LEFT JOIN [dbo].OrderHeader oh ON oh.CustomerId = c.Id LEFT JOIN [dbo].OrderDetail od ON od.OrderHeaderId = oh.Id LEFT JOIN [dbo].Product p ON p.Id = od.ProductId WHERE Sales > 100 GROUP BY p.Code, c