Search Results

Search found 6988 results on 280 pages for 'if else statement'.

Page 19/280 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • using count and group by at the same select statement

    - by Stavros
    Hello, I have an sql select query that has a group by. I want to count all the records after the group by statement. Is there a way for this directly from sql? For example, having a table with users I want to select the different towns and the total number of users select town, count(*) from user group by town I want to have a column with all the towns and another with the number of users in all rows.

    Read the article

  • Java: JPQL select statement

    - by bguiz
    select x from X x where x.a.id = :a_id -- Always 0 objects selected Why does the above JPQL statement not work, but the one below work? select a from A a where a.id = :a_id -- a_obj select x from X x where x.a = :a_obj -- Always correct number of objects selected Neither query throws an exception during execution, but a different number of results are obtained. Thanks

    Read the article

  • Switch statements: do you need the last break? (Javascript mainly)

    - by Jon Raasch
    When using a switch() statement, you add break; in between separate case: declarations. But what about the last one? Normally I just leave it off, but I'm wondering if this has some performance implication I'm not thinking about? I've been wondering about this for a while and don't see it asked elsewhere on Stack-O, but sorry if I missed it. I'm mainly asking this question regarding Javascript, although I'm guessing the answer will apply to all switch() statements.

    Read the article

  • The order of a SQL Select statement without Order By clause

    - by Yousui
    As I know, from the relational database theory, a select statement without an order by clause should be considered has not particular order. But actually in SQL Server and Oracle (I've tested on those 2 platforms), if I query from a table without an order by clause multiple times, I always get the results in the same order. Does this behavior can be relied on? Anyone can help to explain a little? Thanks!

    Read the article

  • sql statement to Expression tree

    - by Joo Park
    I'm wondering how one would translate a sql string to an expression tree. Currently, in Linq to SQL, the expression tree is translated to a sql statement. How does on go the other way? How would you translate select * from books where bookname like '%The%' and year > 2008 into an expression tree in c#?

    Read the article

  • jquery if statement animate back

    - by user295292
    how do i add a if statement when the right image is at +400px then animate back to -400px... when hovering the right image? $('#left img').mouseenter(function() { $('#right img').animate({ left: '+=400px' }, 700); }); $('#right img').mouseenter(function() { $('#left img').animate({ left: '-=400px' }, 700); }); something similar to this - http://www.hyundaiusa.com/ (the two main images on the site)

    Read the article

  • how to create a dynamic sql statement w/ python and mysqldb

    - by Elias Bachaalany
    I have the following code: def sql_exec(self, sql_stmt, args = tuple()): """ Executes an SQL statement and returns a cursor. An SQL exception might be raised on error @return: SQL cursor object """ cursor = self.conn.cursor() if self.__debug_sql: try: print "sql_exec: " % (sql_stmt % args) except: print "sql_exec: " % sql_stmt cursor.execute(sql_stmt, args) return cursor def test(self, limit = 0): result = sql_exec(""" SELECT * FROM table """ + ("LIMIT %s" if limit else ""), (limit, )) while True: row = result.fetchone() if not row: break print row result.close() How can I nicely write test() so it works with or without 'limit' without having to write two queries?

    Read the article

  • mysql statement with nested SELECT - how to improve performance

    - by ernie
    This statement appears inefficient because only one one out of 10 records are selected and only 1 of 100 entries contain comments. What can I do to improve it ? $query = "SELECT A,B,C, (SELECT COUNT(*) FROM comments WHERE comments.nid = header_file.nid) as my_comment_count FROM header_file Where A = 'admin' " edit: I want header records even if no comments are found.

    Read the article

  • Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID

    - by Jian Lin
    Why is the ( ) mandatory in the SQL statement select * from gifts INNER JOIN sentgifts using (giftID); ? The ( ) usually is for specifying grouping of something. But in this case, are we supposed to be able to use 2 or more field names... in the example above, it can be all clear that it is 1 field, is it just that the parser is not made to bypass the ( ) when it is all clear? (such as in the language Ruby).

    Read the article

  • Is using the break statement bad practice?

    - by Lchi
    I've been told by professors and peers at my university that using the break statement is bad practice, but through my coursework haven't come up with a great reason why. Those who claim that it is bad say that it's a "get out of jail free card" and that you can always avoid using it. My guesses for why its considered bad would be that you could possibly skip some cleanup code after the break, or similarly exit some control structure in an inconsistent state. Is there any reason why using break is(n't) bad practice?

    Read the article

  • VB.NET Select...Case Statement Equivalent in C#

    - by Alex Essilfie
    I just started using C# and I've got a couple of issues. Is there any way to code the C# equivalent of the VB.NET Select statement like the following? Select Object.Name.ToString() Case "Name1" 'Do something Case "Name2" 'Do something else Case Else 'Do the default action End Select Any help would be greatly appreciated.

    Read the article

  • IF Statement in VBA

    - by Edmond
    How would I code a IF statement if I was trying to say IF the date today is equal to Monday THEN Have Outlook prepare 3 emails ELSE Have Outlook prepare 2 emails END IF I just need help setting up the "IF the date today is equal to Monday." How would that code look.

    Read the article

  • IF statement error

    - by Jasl
    I have the following columns in TableA TableA Column1 varchar Column2 int Column3 bit I am using this statement IF Column3 = 0 SELECT Column1, Column2 FROM TableA WHERE Column2 > 200 ELSE SELECT Column1, Column2 FROM TableA WHERE Column2 < 200 But the statment does not compile. It says Invalid Column Name 'Column3'

    Read the article

  • Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing

    - by Paresh
    I am getting the error from the application as following with SQL server 2005 "Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0" How can i find the stage where this error raised? how can i found the missing transaction or the stored procedure where it is not committ or rollback?

    Read the article

  • jquery if else, why does not work?

    - by Cesar Lopez
    In the following function it goes through the if and the else, why is that? function test(){ $(".notEmpty").each(function() { if($(this).val() === ""){ alert("Empty Fields!!"); return; } else{ AddRow_OnButtonClick('tblMedicationDetail',6); } }); } Is there any if and else statement on jquery that I am not aware of? Thanks

    Read the article

  • How do I reference sqlite db column to use in update statement

    - by user244190
    I am trying to update a datetime column in an android sqlite db to use international date format (yyyy-mm-dd) instead of the current format (mm/dd/yyyy). I want to use the sqlite date() function to reformat the current value of the column. I thought it would be as simple as the following: update tblename set thedate = date(thedate) but the above does not work. How would i write the sql statement to accomplish this? thanks patrick

    Read the article

  • Ternary operator in if-statement?

    - by Pindatjuh
    I've written the following if-statement in Java: if(methodName.equals("set" + this.name) || isBoolean() ? methodName.equals("is" + this.name) : methodName.equals("get" + this.name)) { ... } Is this a good practice to write such expressions in if, to separate state from condition? And can this expression be simplified?

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >