Search Results

Search found 1369 results on 55 pages for 'over clause'.

Page 5/55 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Using a comma seperated data in MYSQL "IN" clause

    - by Sashi Kant
    I have a column in one of my table where I store multiple ids seperated by comma's. Is there a way in which I can use this column's value in the "IN" clause of a query. The column(city) has values like 6,7,8,16,21,2 I need to use as Select * from table where e_ID in (Select city from locations where e_Id=?) I am satisfied with Crozin's answer, but I am open to suggestions, views and options. Feel free to share your views.

    Read the article

  • SQL WHERE.. IN clause multiple columns

    - by ala
    i need to implement the following query in SQL Server select * from table1 WHERE (CM_PLAN_ID,Individual_ID) IN ( Select CM_PLAN_ID, Individual_ID From CRM_VCM_CURRENT_LEAD_STATUS Where Lead_Key = :_Lead_Key ) but the WHERE..IN clause allows only 1 column. How to compare 2 or more columns with another inner select?

    Read the article

  • SQL: HAVING clause

    - by Craig Johnston
    See the following SQL statement: SELECT datediff("d", MAX(invoice.date), Now) As Date_Diff, MAX(invoice.date) AS max_invoice_date, customer.number AS customer_number FROM invoice INNER JOIN customer ON invoice.customer_number = customer.number GROUP BY customer.number If the the following was added: HAVING datediff("d", MAX(invoice.date), Now) > 365 would this simply exclude rows with Date_Diff <= 365? What should be the effect of the HAVING clause here?

    Read the article

  • DISTINCT clause in SQLite

    - by Eye of Hell
    Hello. Recently i found that SQLite don't support DISTINCT ON() clause that seems postgresql-specific. For exeample, if i have table t with columns a and b. And i want to select all items with distinct b. Is the following query the only one and correct way to do so in SQLite? select * from t where b in (select distinct b from t)

    Read the article

  • Problems with MySQL OR clause

    - by Simon
    I have a problem with AND and OR clause in SQL. Here is my query: SELECT `act1`.`name`, `act1`.`surname`, `act2`.`name`, `act2`.`surname`, `act3`.`name`, `act3`.`surname` FROM `videos`, `actors` AS act1, `actors` AS act2, `actors` AS act3 WHERE `videos`.`ident` = 'somethink' AND ( `act1`.`id` = `videos`.`id_actor1` OR `act2`.`id` = `videos`.`id_actor2` OR `act3`.`id` = `videos`.`id_actor3` ) It returns me all variations of {name, surname}, but I want the name and surname of first exactly, second and thirth, if they exist.

    Read the article

  • Query having 2 Where Clause

    - by Harsha M V
    i am trying to login and want to validate username and password against the records in the database. I am not sure how to pass two Where clause public Boolean login(String username, String password) throws SQLException { Cursor mCursor = db.query(TABLE_USERS, new String[] { ID, KEY_NAME, KEY_USERNAME}, KEY_USERNAME + "=" + "'"+username+"'", KEY_PASSWORD + "=" + "'"+password+"'", null, null, null, null, null); if (mCursor.moveToFirst()) { return true; } return false; } Am getting a Syntax Error.

    Read the article

  • Unknown Column In Where Clause

    - by Corpo
    I have a simple query: SELECT u_name AS user_name FROM users WHERE user_name = "john"; I get "Unknown Column 'user_name' in where clause". Can I not refer to 'user_name' in other parts of the statement even after select 'u_name as user_name'?

    Read the article

  • morethan one between clause

    - by tismon
    hi how can i use more than one 'between' clause in mysql query ? like if i want to select students having height between 20 and 25 and weight between 50 and 70.. thanks in advance tismon

    Read the article

  • Parameterizing a SQL IN clause?

    - by Jeff Atwood
    How do I parameterize a query containing an IN clause with a variable number of arguments, like this one? select * from Tags where Name in ('ruby','rails','scruffy','rubyonrails') order by Count desc In this query, the number of arguments could be anywhere from 1 to 5. I would prefer not to use a dedicated stored procedure for this (or XML), but if there is some fancy SQL Server 2008 specific way of doing it elegantly, I am open to that.

    Read the article

  • MySQL 'user_id' in where clause is ambiguous problem

    - by HoMe
    How can I correct the problem I keep getting from the code below which states 'user_id' in where clause is ambiguous. Thanks for the help in advance. Here is the mysql table. SELECT user.*, user_info.* FROM user INNER JOIN user_info ON user.user_id = user_info.user_id WHERE user_id='$user_id'

    Read the article

  • Output columns not in destination table?

    - by lance
    SUMMARY: I need to use an OUTPUT clause on an INSERT statement to return columns which don't exist on the table into which I'm inserting. If I can avoid it, I don't want to add columns to the table to which I'm inserting. DETAILS: My FinishedDocument table has only one column. This is the table into which I'm inserting. FinishedDocument -- DocumentID My Document table has two columns. This is the table from which I need to return data. Document -- DocumentID -- Description The following inserts one row into FinishedDocument. Its OUTPUT clause returns the DocumentID which was inserted. This works, but it doesn't give me the Description of the inserted document. INSERT INTO FinishedDocument OUTPUT INSERTED.DocumentID SELECT DocumentID FROM Document WHERE DocumentID = @DocumentID I need to return from the Document table both the DocumentID and the Description of the matching document from the INSERT. What syntax do I need to pull this off? I'm thinking it's possible only with the one INSERT statement, by tweaking the OUTPUT clause (in a way I clearly don't understand)? Is there a smarter way that doesn't resemble the path I'm going down here? EDIT: SQL Server 2005

    Read the article

  • SQL WHERE clause not returning rows when field has NULL value

    - by JohnB
    Ok, so I'm aware of this issue: When SET ANSI_NULLS is ON, all comparisons against a null value evaluate to UNKNOWN SQL And NULL Values in where clause SQL Server return Rows that are not equal < to a value and NULL However, I am trying to query a DataTable. I could add to my query: OR col_1 IS NULL OR col_2 IS NULL for every column, but my table has 47 columns, and I'm building dynamic SQL (string concatenation), and it just seems like a pain to do that. Is there another solution? I was to bring back all the rows that have NULL values in the WHERE comparison. UPDATE Example of query that gave me problems: string query = col_1 not in ('Dorothy', 'Blanche') and col_2 not in ('Zborna', 'Devereaux') grid.DataContext = dataTable.Select(query).CopyToDataTable(); (didn't retrieve rows if/when col_1 = null and/or col_2 = null)

    Read the article

  • MDX Except function in where clause

    - by rfders
    Hi, i'm having problem restricting a query in mdx, using except function at where clause. i need to retrieved a set of data but which not in an specific set. Then i created the next query: select {[Measures].[Amount], [Measures].[Transaction Cost], [Measures].[Transaction Number]} ON COLUMNS,{[ManualProcessing].[All ManualProcessings].[MAGNETICSTRIPE], ManualProcessing].[All ManualProcessings].[MANUAL]} ON ROWS FROM [Transactions] where except([Product].[All Products].Children,{[Product].[All Products].[Debit}) apparently this works fine, but when i try to add another restriction to slicer, i got this error: No function matches signature (Set,Member). I'm currently working on mondrian 3.1 Is it possible to add multiple restriction to slicer when im sing the except funtion ? are there any other way to get this ? thanks in advance.

    Read the article

  • Conditional Operator in SQL Where Clause

    - by Marc
    I'm wishing I could do something like the following in SQl Server 2005 (which I know isnt valid) for my where clause. Sometimes @teamID (passed into a stored procedure) will be the value of an existing teamID, otherwise it will always be zero and I want all rows from the Team table. I researched using Case and the operator needs to come before or after the entire statement which prevents me from having a different operator based on the value of @teamid. Any suggestions other than duplicating my select statements. declare @teamid int set @teamid = 0 Select Team.teamID From Team case @teamid when 0 then WHERE Team.teamID > 0 else WHERE Team.teamID = @teamid end

    Read the article

  • using a php variable in the WHERE clause of a mysql query

    - by user1262890
    I'm running a very simple query that I think should work. The only thing that I haven't done before is put a php variable in the WHERE clause of the query. The variable $X is a numerical value, say 100. When I run this query, I just get a value of 0 returned. Am I doing something obviously stupid? SELECT generator_64k.n FROM generator_64k WHERE generator_64k.n<= '$X' I've looked around the web and also tried this: SELECT generator_64k.n FROM generator_64k WHERE generator_64k.n<= '" . $X . "' But this also just returns 0. Any ideas? Thanks in advance.

    Read the article

  • Odd compiler error on if-clause without braces

    - by DisgruntledGoat
    The following Java code is throwing a compiler error: if ( checkGameTitle(currGame) ) ArrayList<String> items = parseColumns( tRows.get(rowOffset+1), currGame, time, method ); checkGameTitle is a public static function, returning a boolean. The errors are all of the type "cannot find symbol" with the symbols being variable ArrayList, variable String and variable items. However, if I add {curly braces} then the code compiles with no errors. Why might this be? Is there some ambiguity on the if clause without them?

    Read the article

  • sql-access: HAVING clause and != operator

    - by every_answer_gets_a_point
    i am new to access sql and i built a select statement that looks like this: SELECT [Lab Occurrence Form].[Practice Code], Count([Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]) AS [CountOf1 0 Preanalytical (Before Testing)], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)] FROM [Lab Occurrence Form] WHERE ((([Lab Occurrence Form].[Occurrence Date]) Between #9/1/2009# And #9/30/2009#)) having ([CountOf1 0 Preanalytical (Before Testing)] != 0) GROUP BY [Lab Occurrence Form].[Practice Code], [Lab Occurrence Form].[1 0 Preanalytical (Before Testing)]; its not liking my HAVING clause. what is wrong with it? how do i do a != ??

    Read the article

  • java checked exception in a catch clause compilation error

    - by srandpersonia
    Hi, I was expecting an compilation error in the following program because of the throw statement in the catch block as IOException is a checked exception and it is not caught by another try block within the catch block. But I am getting "Hurray!" printed. Any explanation would be much appreciated. According to JLS 11.2.3, http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html It is a compile-time error if a method or constructor body can throw some exception type E when both of the following hold: * E is a checked exception type * E is not a subtype of some type declared in the throws clause of the method or constructor. import java.io.*; public class Test{ public static void main(String args[]) { System.out.println(method()); } public static int method() { try{ throw new Exception(); } catch(Exception e){ throw new IOException(); //No compile time error } finally{ System.out.println("Hurray!"); } } } Thanks in advance.

    Read the article

  • tsql - using internal stored procedure as parameter is where clause

    - by vondip
    Hi all, I'm tryng to build a stored procedure that makes use of another stored proceudre. Taking its result and using it as part of its where clause, from some reason I receive an error: Invalid object name 'dbo.GetSuitableCategories'. Here is a copy of the code: select distinct top 6 * from ( SELECT TOP 100 * FROM [dbo].[products] products where products.categoryId in (select top 10 categories.categoryid from [dbo].[GetSuitableCategories] ( -- @Age -- ,@Sex -- ,@Event 1, 1, 1 ) categories ORDER BY NEWID() ) --and products.Price <=@priceRange ORDER BY NEWID() )as d union select * from ( select TOP 1 * FROM [dbo].[products] competingproducts where competingproducts.categoryId =-2 --and competingproducts.Price <=@priceRange ORDER BY NEWID() ) as d and here is [dbo].[GetSuitableCategories] : if (@gender =0) begin select * from categoryTable categories where categories.gender =3 end else begin select * from categoryTable categories where categories.gender = @gender or categories.gender =3 end Thank you very much!~

    Read the article

  • Linq with a long where clause

    - by Jeremy Roberts
    Is there a better way to do this? I tried to loop over the partsToChange collection and build up the where clause, but it ANDs them together instead of ORing them. I also don't really want to explicitly do the equality on each item in the partsToChange list. var partsToChange = new Dictionary<string, string> { {"0039", "Vendor A"}, {"0051", "Vendor B"}, {"0061", "Vendor C"}, {"0080", "Vendor D"}, {"0081", "Vendor D"}, {"0086", "Vendor D"}, {"0089", "Vendor E"}, {"0091", "Vendor F"}, {"0163", "Vendor E"}, {"0426", "Vendor B"}, {"1197", "Vendor B"} }; var items = new List<MaterialVendor>(); foreach (var x in partsToChange) { var newItems = ( from m in MaterialVendor where m.Material.PartNumber == x.Key && m.Manufacturer.Name.Contains(x.Value) select m ).ToList(); items.AddRange(newItems); } Additional info: I am working in LINQPad.

    Read the article

  • SQL Server WHERE Clause using Temporary Columns

    - by AbeP
    Hi all, I have the following query, which uses a CASE statement. Is there anyway to add into the where clause WHERE IsBusinessDayFinal = 0? without using a temporary table? thanks so much! SELECT ac.DateTimeValue, CASE WHEN pc.IsBusinessDay IS NOT NULL THEN pc.IsBusinessDay ELSE ac.IsBusinessDay END AS IsBusinessDayFinal, ac.FullYear, ac.MonthValue, ac.DayOfMonth, ac.DayOfWeek, ac.Week FROM [dbo].[AdminCalendar] ac LEFT JOIN [dbo].ProjectCalendar pc ON ac.DateTimeValue = pc.DateTimeValue AND pc.ProjectId = @projectId WHERE ac.DateTimeValue >= @startDate AND ac.DateTimeValue <= @finishDate;

    Read the article

  • SQL Operators as text in where clause

    - by suggy1982
    I have the following table, which is used for storing bandings. The table is maintained via a web frontend. CREATE TABLE [dbo].[Banding]( [BandingID] [int] IDENTITY(1,1) NOT NULL, [ValueLowerLimitOperator] [varchar](10) NULL, [ValueLowerLimit] [decimal](9, 2) NULL, [ValueUpperLimitOperator] [varchar](10) NULL, [ValueUpperLimit] [decimal](9, 2) NULL, [VolumeLowerLimitOperator] [varchar](10) NULL The operator fields store values such as < = <=. I want to get to a position where I can use the operators values stored in the table in a case statement in a where clause. Like this. SELECT * FROM table WHERE CASE ValueLowerLimitOperator WHEN '<' THEN VALUE < X WHEN '>' THEN VALUE > X END rather than having to write mutiple case or if statements for each permutation. Does anyone have any suggestions how I can decode the operators values stored in the table as part of my query and then use them in a case/where statement?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >