Search Results

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

Page 126/280 | < Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >

  • SQL Update to the SUM of its joined values

    - by CL4NCY
    Hi, I'm trying to update a field in the database to the sum of its joined values: UPDATE P SET extrasPrice = SUM(E.price) FROM dbo.BookingPitchExtras AS E INNER JOIN dbo.BookingPitches AS P ON E.pitchID = P.ID AND P.bookingID = 1 WHERE E.[required] = 1 When I run this I get the following error: "An aggregate may not appear in the set list of an UPDATE statement." Any ideas?

    Read the article

  • Do i need to dispose of MySqlCommand?

    - by acidzombie24
    I find it incredibly annoying to write a using statement on every one of my queries (which require its own command or write parameters.clear()) which sometimes require declaring variables outside of the using block. Its so incredibly annoying and looks much dirtier compared to the version without disposing the object. Do i need to dispose of it? what happens if i dont? I do know its good practice to dispose of an object when it has that interface.

    Read the article

  • How to SELECT the last 10 rows of an SQL table which has no ID field?

    - by Edward Tanguay
    I have an MySQL table with 25000 rows. This is an imported CSV file so I want to look at the last ten rows to make sure it imported everything. However, since there is no ID column, I can't say: SELECT * FROM big_table ORDER BY id DESC What SQL statement would show me the last 10 rows of this table? The structure of the table is simply this: columns are: A, B, C, D, ..., AA, AB, AC, ... (like Excel) all fields are of type TEXT

    Read the article

  • Select...Case VB.NET to C# Equivalent

    - by Alex Essilfie
    I just started using C# and I've got a couple of issues. I hook several controls to one event handler as in the following and I want to perform a slightly different action for each control: Private Sub Button_Click(sender as Object, e as EventArgs) _ Handles button1.Click, Button2.Click 'do a general activity Select CType(sender, Button).Name Case button1.Name 'do something Case button2.Name 'do something else Case Else 'do the defalut action End Select End Sub Is there any way of doing the above select statement in C# without having to use nested ifs?

    Read the article

  • How do I implement Advanced combobox in CakePHP

    - by skr
    I have implemented combobox in cakephp using following statement - echo $form->select('brand_id',array($brands),null,array(),'Choose Brand'); for brand and input form for category - echo $form->input('category_id',array('type'=>'select',$categories,'empty'=>'Choose Category')); but none of above option allows me to add my text input to brand or category, like say I want to add an input which is not there in the combobox, how should i go about it. Like a link in the combobox or textbox in combobox? -skr

    Read the article

  • How do I select distinct rows where a column may have a number of the same values but all their 2nd

    - by Martin Rose
    I have a table in the form: test_name| test_result | test1 | pass | test2 | fail | test1 | pass | test1 | pass | test2 | pass | test1 | pass | test3 | pass | test3 | fail | test3 | pass | As you can see all test1's pass while test2's and test3's have both passes and fails. Is there a SQL statement that I can use to return the distinct names of the tests that only pass? E.g. test1

    Read the article

  • Dispose a Web Service Proxy class?

    - by Matt
    When you create and use a Web Service proxy class in the ASP.Net framework, the class ultimately inherits from Component, which implements IDisposable. I have never seen one example online where people dispose of a web proxy class, but was wondering if it really needs to be done. When I call only one method, I normally wrap it in a using statement, but if I have a need to call it several times throughout the page, I might end up using the same instance, and just wondered what the ramifications are of not disposing it.

    Read the article

  • Need help converting SQL to EF4 please

    - by Ken Eldridge
    I need help converting this SQL statement, into EF4: Select Posts.PostID, Post, Comment from Posts left join Comments on posts.PostID = Comments.PostID Where CommentID not in ( Select PostID from Votes where VoteTypeID = 4 --4 = flagged comment type ) In my database, the Votes table stores either the PostID of reported posts, or CommentID of reported comments in the column Votes.PostID Thanks in advance!

    Read the article

  • WordPress - moving from one host to another

    - by Maor
    I am trying to move a WordPress installation from one server to another one, including all of the SQL data, and the file-system data (photos,template files). I just have a problem changing the URLs in the database, since I need to replace the new URL with the old one. I would love to have some suggestions about how can I replace the URLs (maybe there's a rplace statement in SQL?) Thanks in advance.

    Read the article

  • Which is the correct way to use PDO in PHP?

    - by Runner
    One from here: $sth->execute(array(':calories' => $calories, ':colour' => $colour)); The other from here: /*** reassign the variables again ***/ $data = array('animal_id'=>4, 'animal_name' => 'bruce'); /*** execute the prepared statement ***/ $stmt->execute($data); My question is: :key or key ? Sorry I don't have the PHP environment here.

    Read the article

  • .Net Windows application

    - by ksmps
    I am trying to Insert a record in MS Access DB using OLEDB in windows application. I am getting an error "missing semicolon at end of sql statement" there is no syntax error in sql insert statment.

    Read the article

  • sql server - select top and bottom rows

    - by Adrian Faciu
    Hi, I'm using Sql Server 2005 and i'm trying to achieve something like: In the same select statement i want to get the first x rows and the last x rows. SELECT TOP(5) BOTTOM(5) Of course 'bottom' does not exist so i need other solution. I believe there is an easy and elegant solution that i'm not getting. Doing the select again with Group By Desc is not an option. Thanks.

    Read the article

  • oracle blob text search

    - by Skay
    Is it possible to search through blob text using sql statement? I can do select * from $table where f1 like '%foo%' if the f1 is varchar, how about f1 is a blob? Any counter part for this?

    Read the article

  • Is it possible to use 'else' in a python list comprehension?

    - by Josh
    Here is the code I was trying to turn into a list comprehension: table = '' for index in xrange(256): if index in ords_to_keep: table += chr(index) else: table += replace_with Is there a way to add the else statement to this comprehension? table = ''.join(chr(index) for index in xrange(15) if index in ords_to_keep) Also, would I be right in concluding that a list comprehension is the most efficient way to do this?

    Read the article

  • Can I select a set of rows from a table and directly insert that into a table or the same table in S

    - by VJ
    Hi I guess we cannot do this but was just curious if I could do something like - Select * from Employee where EmployeeId=1 and then use the data in the above statement and directly insert into a table with just changing the employeeid...or just this way- insert into Employee ( Select * from Employee where EmployeeId=1) its probably stupid from my side...but I just felt the need to do this a lot of times...so just was curious if there was any way to achieve it..

    Read the article

  • How to write this query in Linq2Sql

    - by RememberME
    I have a table company which holds the company_id, company_name and other details. I have a table subcontracts which has a company_id column that maps to company.company_id. How can I write a select statement to get all companies which have not been assigned to a subcontract? IE The company_id cannot be found in subcontracts.company_id

    Read the article

  • Setting 0/1-to-1 relationship in SQLAlchemy?

    - by Timmy
    is there a proper way of setting up a 0/1-to-1 relationship? i want to be able to check if the related item exists without creating it: if item.relationship is None: item.relationship = item2() but it creates the insert statements on the if statement

    Read the article

  • Rails - Find Condition of two model fields

    - by ChrisWesAllen
    I'm trying to find the results of a model where it queries as the result of two conditions. I have a search tag that looks for Model.find(:all, :conditions => "name LIKE params[search]") but I'd like for the search to find all records where "name LIKE params[search] or description LIKE params[search] . Is there any way to add an OR into a condition in rails? or should I make an if statement?

    Read the article

  • Crontab sets 18:00 to 09:00

    - by abubacker
    I just want to set a crontab using that I want to make a program run at every 15 minutes from 18:00 to 09:00 I have given this statement and waited but I don't think it is working */15 18-9 * * 1-6 Program_name Any suggestion would be greatly appreciated

    Read the article

  • Why do updates inside of a SQL transaction still need disk IO?

    - by usr
    In SQL Profiler you can see that very simple updates to a table by primary key take about 10-30ms each. On about every 10th update the write column shows 1, on all other updates it shows 0. This must mean that about every 10th update statement still requires disk IO. I wonder why that is. Would it not be more efficient queue up all IO until the transaction commits?

    Read the article

< Previous Page | 122 123 124 125 126 127 128 129 130 131 132 133  | Next Page >