Search Results

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

Page 87/280 | < Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >

  • A better understanding of the relations beetween database tables

    - by Nistor Alexandru
    Hi I am trying to get a better understanding of relational databases and there is something that I keep bumping into and don't understand.Let's take this two tables: In this case Login.ID is the primary key with auto_increment set and Profile.ID_LOGIN is the Foreign KEY.When a user is created and it's username and password is stored in the login database does the ID coresponding to the curesnt username and password get automaticly added into ID_LOGIN or do I have to create an SQL statement to do this? If I have to create a SQL statement how should I aproach adding the ID_LOGIN to make sure I am adding it corectly?

    Read the article

  • indexing question

    - by user522962
    I have a table w/ 3 columns: name, phone, date. I have 3 indexes: 1 on phone, 1 on date and 1 on phone and date. I have the following statement: SELECT * FROM ( SELECT * FROM people WHERE phone IS NOT NULL ORDER BY date DESC) as t GROUP BY phone Basically, I want to get all unique phone numbers ordered by date. This table has about 2.5 million rows but takes forever to execute....are my indexes right? UPDATE: My EXPLAIN statement comes back with 2 rows: 1 for primary table and 1 for derived table. It says I am using temporary and using filesort for my primary table. For my derived table, it says my possible keys are (phone), and (phone, date) but it is using filesort.

    Read the article

  • AJAX in ASP.NET - How do I check a checkbox and have the action reflected in the database?

    - by hamlin11
    This is about as beginner as it gets regarding AJAX, but here it goes. I want to have one checkbox somewhere on an ASP.NET web form (ASPX). When the user clicks the checkbox, I want one of those spinning indicators to show. While that spinning indicator is showing, I want an update operation to occur in the database to reflect that the user has intended for that checkbox to be checked. update MyTable set CheckboxChecked = 1 Then, as soon as the update operation has occurred, I want that to be reflected in the checkbox by removing the spinning indicator and replacing it with the standard checked checkbox. I'm guessing this is done with an UpdatePanel and possibly an update statement followed by a looped call to a select statement... but I have never used AJAX before and have no idea how to go about it. Thanks!

    Read the article

  • How can I fake sql data while preserving statements without commenting my server-side code?

    - by Fedor
    I have to use hardcoded values for certain fields because at this moment we don't have access to the real data. When we do get access, I don't want to go through a lot of work uncommenting. Is it possible to keep this statement the way it is, except use '25' as the alias for ratecode? IF(special.ratecode IS NULL, br.ratecode, special.ratecode) AS ratecode, I have about 8 or so IF statements similar to this and I'm just too lazy ( even with vim ) to re-append while commenting out each if statement line by line. I would have to do this: $sql = 'SELECT u.*,'; // IF ( special.ratecode IS NULL, br.ratecode, special.ratecode) AS ratecode $sql.= '25 AS ratecode';

    Read the article

  • Accessing hard-coded data in a C# application.

    - by haymansfield
    I'm trying to avaid hardcoding in a .net 2.0 soon to be 3.5 application. I have a large enumneration which I wish to map 1 to 1 to a set of strings. Each enumerated value will also map to 1 of 2 values indicating an action. The existing code does this with a big switch statement but this seems ugly to me. Is there a better way of storing and accessing the data? I've thought about resx files but when you consider that the designer file contains just as many hardcoded values it seems a little pointless. Is embedding an xml file in the assembly a good idea? Is a big switch statement not as bad as it seems? Is there a better solution?

    Read the article

  • How to change a vairable type in C#?

    - by Mosho Mulan
    I wanted to use something like this: if(x==5) { var mydb= ........ ; } else { var mydb = ........ ; } but it didn't work because I can't declare a variable inside if statement. So I tried to do this: var mydb; if (x==5) { mydb= ............. ; } else { mydb=.............; } but id didn't work either because I had to initialize the variable (mydb). So the question is: I don't necessarily know the type of the variable, can I declare it anyway and then change the type inside the if statement?

    Read the article

  • C# Console Application - Odd behaviour - char '\a'

    - by KHT
    After extensive debugging of an application, I noticed the console window would hang when searching text for the char '\a'. The goal is to strip out characters from a file. The console window would always hang upon exiting the program, and it would make it to the last statement of main. I removed the '\a' from the switch statement and the console application does not hang anymore. Any idea why? I still need to strip out the char '\a', but cannot get the application to work without hanging. switch (c) { case '\t': //Horizontal Tab case '\v': //Vertical Tab case '\n': //Newline case '\f': //Form feed case '\r': //carriage return case '\b': //Backspace case '\x7f': //delete character case '\x99': //TM Trademark case '\a': //Bell Alert **REMOVED THIS** return true; }

    Read the article

  • what is wrong with my create table SQL?

    - by George2
    Hello everyone, I am using SQL Server 2008 management studio to execute the following SQL statements, and here is the related error message from SQL Server management studio. Any ideas what is wrong? SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO Create TABLE [dbo].[BatchStatus]( [BatchID] [uniqueidentifier] NOT NULL CONSTRAINT [PK_BatchStatus_ID], [BatchStatus] [int] NULL, CONSTRAINT [PK_BatchStatus_ID] PRIMARY KEY CLUSTERED ( [BatchID] ASC )WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY] ) ON [PRIMARY] GO Msg 102, Level 15, State 1, Line 3 Incorrect syntax near ','. Msg 319, Level 15, State 1, Line 8 Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. thanks in advance, George

    Read the article

  • Performance effect of using print statements in Python script

    - by Sudar
    I have a Python script that process a huge text file (with around 4 millon lines) and writes the data into two separate files. I have added a print statement, which outputs a string for every line for debugging. I want to know how bad it could be from the performance perspective? If it is going to very bad, I can remove the debugging line. Edit It turns out that having a print statement for every line in a file with 4 million lines is increasing the time way too much.

    Read the article

  • INSERT INTO ... SELECT ... vs dumping/loading a file in MySQL

    - by Daniel Huckstep
    What are the implications of using a INSERT INTO foo ... SELECT FROM bar JOIN baz ... style insert statement versus using the same SELECT statement to dump (bar, baz) to a file, and then insert into foo by loading the file? In my messing around, I haven't seen a huge difference. I would assume the former would use more memory, but the machine that this runs on has 8GB of RAM, and I never even see it go past half used. Are there any huge (or long term) performance implications that I'm not seeing? Advantages/disadvantages of either?

    Read the article

  • Can't use method return value in write context; Not sure where to go from here

    - by Morgan Green
    This is my source for the variable. <?php if ($admin->get_permissions()=3) echo 'Welcome to the Admin Panel'; else echo 'Sorry, You do not have access to this page'; ?> And the code that I'm actually trying to call with the if statement is: public function get_permissions() { $username = $_SESSION['admin_login']; global $db; $info = $db->get_row("SELECT `permissions` FROM `user` WHERE `username` = '" . $db->escape($username) . "'"); if(is_object($info)) return $info->permissions; else return ''; } This should be a simple way to call my pages that the user is authorized for by using an else if statement. Or So I thought

    Read the article

  • MySQL Join a Table if Exists Question

    - by swhitlow
    I have a DB which has a table called "config". This table could possibly have a "config_cstm" table that is related by the id to the config table. I was wondering - is there a way to dynamically check for the existence of this table in one simple select statement? In other words, something like: "select * from config (IF EXISTS config_cstm THEN LEFT OUTER JOIN config_cstm ON config.id = config_cstm.id_c" I know how I would go about checking for the existence of an existing table in PHP. I was wanting to do this all in one MySQL statement though. Any suggestions? Thanks!

    Read the article

  • Strange Locking Behaviour in SQL Server 2005

    - by SQL Learner
    Can anyone please tell me why does the following statement inside a given stored procedure returns repeated results even with locks on the rows used by the first SELECT statement? BEGIN TRANSACTION DECLARE @Temp TABLE ( ID INT ) INSERT INTO @Temp SELECT ID FROM SomeTable WITH (ROWLOCK, UPDLOCK, READPAST) WHERE SomeValue <= 10 INSERT INTO @Temp SELECT ID FROM SomeTable WITH (ROWLOCK, UPDLOCK, READPAST) WHERE SomeValue >= 5 SELECT * FROM @Temp COMMIT TRANSACTION Any values in SomeTable for which SomeValue is between 5 and 10 will be returned twice, even though they were locked in the first SELECT. I thought that locks were in place for the whole transaction, and so I wasn't expecting the query to return repeated results. Why is this happening?

    Read the article

  • Combining IN and NOT IN in SQL as single result

    - by UltraVi01
    I apologize for the vague title. I am attempting to write a query that returns an alias column with matching values (resulting from an IN) as well as an alias column with values that do not match (using NOT IN). I want the result set to have: userId | matches | nonmatches. I currently have the following query which returns the matches as expected. I am having trouble getting the nonmatches in the result set -- that is, from a NOT IN statement SET @userId = 9; SELECT ug.user_id, COUNT(DISTINCT goal_id) as matches FROM user_goal ug WHERE ug.user_id!=@userId AND goal_id IN (SELECT iug.goal_id FROM user_goal iug WHERE user_id=@userId) GROUP BY user_id ORDER BY matches DESC LIMIT 4 So, the NOT IN would look something like this: goal_id NOT IN(SELECT uggg.goal_id FROM user_goal uggg WHERE user_id=@userId) AS nonmatches I am just not sure how to incorporate the NOT IN statement in my query so I get all the results

    Read the article

  • JQuery if statements?

    - by SLAPme
    New to JQuery and was wondering how can I put the following JQuery code in an if statement so that it only runs when the submit button is clicked and does nothing when not clicked I know I'm using the $(".save-button").click(function() is there a way to put it in an if statement? JQuery code. $(function() { $(".save-button").click(function() { $.post($("#contact-form").attr("action"), $("#contact-form").serialize(), function(html) { $("div.contact-info-form").html(html); $('#changes-saved').append('<li>Changes saved!</li>').show().pause(1000).hide(); }); return false; // prevent normal submit }); });

    Read the article

  • ADO Execute not reading a line of SQL code?

    - by llaskin
    My code is below: var statement = "test_oracle.sql"; F = aqFile.OpenTextFile(statement, aqFile.faRead, aqFile.ctANSI); F.Cursor = 0; while(! F.IsEndOfFile()){ s = F.ReadLine(); oResult = Project.Variables.oConnection.Execute_(s); CheckResult(oResult, "Unable to run SQL script to add documents"); The first line that "s" reads is: set serverout on size 10000 An error is returned as "ORA-00922: missing or invalid option" Can anyone provide guidance?

    Read the article

  • You can't specify target table 'b' for update in FROM clause

    - by elo
    I need to know where did i do wrong in this sql statement. I try to find solution in previous threads with similar problem but none can solve my problem. so i think maybe my statement is actually wrong. update table1 b left join table2 m on b.ICNO=m.ICNO set b.SalMoveMth = '01' where m.Status!='6' and (DATE_FORMAT(startDateSand,'%m')='10' or DATE_FORMAT(startDateSand,'%m')='11' or DATE_FORMAT(startDateSand,'%m')='12') and ((select SalMoveMth from table1 where ICNO=table2.ICNO order by SalMoveMthStDt desc limit 1)!='10'). Thank You.

    Read the article

  • Understanding memory leak in Android app.

    - by sat
    After going through few articles about performance, Not able to get this statement exactly. "When a Drawable is attached to a view, the view is set as a callback on the drawable" Soln: "Setting the stored drawables’ callbacks to null when the activity is destroyed." What does that mean, e.g. In my app , I initialize an imageButton in onCreate() like this, imgButton= (ImageButton) findViewById(R.id.imagebtn); At later stage, I get an image from an url, get the stream and convert that to drawable, and set image btn like this, imgButton.setImageDrawable(drawable); According to the above statement, when I am exiting my app, say in onDestroy() I have to set stored drawables’ callbacks to null, not able to understand this part ! In this simple case what I have to set as null ? I am using Android 2.2 Froyo, whether this technique is required, or not necessary.

    Read the article

  • Regex if-else expression

    - by craig
    I'm trying to extract the # of minutes from a text field using Oracle's REGEXP_SUBSTR() function. Data: Treatment of PC7, PT1 on left. 15 min. 15 minutes. 15 minutes 15 mins. 15 mins 15 min. 15 min 15min 15 In each case, I'm hoping to extract the '15' part of the string. Attempts: \d+ gets all of the numeric values, including the '7' and '1', which is undesirable. (\d)+(?=\ ?min) get the '15' from all rows except the last. (?((\d)+(?=\ ?min))((\d)+(?=\ ?min))|\d+), an if-else statement, doesnt' match anything. What is wrong with my if-else statement?

    Read the article

  • setting variables and values in html & js

    - by air
    i have one js file in that js file i have following variables var image_path="images"; var style_path="style"; i want to use these variables in html file(s) like in image statement <img src="path from js/logo.gif"> or in style sheet statement <link rel="stylesheet" href="path from js/constant.css" type="text/css" /> Basic idea behind this is: if we change name of image folder or path of image folder we only do change in one JS file not 1000 html files. same for style sheet. or any other way to do same in java script or Jquery Thanks

    Read the article

  • Using NUnit Testing How Can I test that a Save Dialog Box was displayed on the screen?

    - by user512915
    I am trying to programatically click the "save" button and test that the windows Save Dialog box appears: I have everything but the assert statement I believe. I don't know how to assert that my custom SaveDialogBox appears to the user. [test] public void Method_WhenThePersonIsNotfound_ClickingTheButtonSavesLetterToWordDocument { //arrange CreateNewPage(); //creates IE window enters fields and clicks submit on first page. //act this.InternetExplorerDriver.FindElementById("SaveForm").Click(); //assert //Assert statement to verify that when button was clicked the save dialog box to save the letter in word appears.

    Read the article

  • Visual Basic Display Square

    - by user1724157
    Alright I'm currently lost on a particular assignment I have for a class. I've seen many examples of this app but none of them see to help my problem is as follows: Write a Sub procedure "DisplaySquare" to display the solid square. The size should be specified by the integer parameter "size". The character that fills the square should be specified by the string parameter "fillCharacter. Use a For...Next statement nested within another For...Next statement to create the square. The outer For...Next specifies what row is currently being displayed. The inner For...Next appends all the characters that form the row to a display string. So it should come out like as follows: if a user enters "8" and "#" ######## ######## ######## ######## ######## ######## ######## ######## Any help would be appreciated.

    Read the article

  • Prevent "jQuery( html )" from triggering the browser to request images and other referenced content

    - by Chris Dutrow
    Using jQuery to create new DOM elements from text. Example: jQuery('<div><img src="/some_image.gif"></img></div>'); When this statement is executed, it causes the browser to request the file 'some_img.gif' from the server. Is there a way to execute this statement so that the resulting jQuery object can be used from DOM traversal, but not actually cause the browser to hit the server with requests for images and other referenced content? Example: var jquery_elememnts = jQuery('<div><img class="a_class" src="/some_image.gif"></img></div>'); var img_class = jquery_elememnts.find('img').attr('class'); The only idea I have now is to use regex to remove all of the 'src' tags from image elements and other things that will trigger the browser requests before using jQuery to evaluate the HTML. How can jQuery be used to evaluate HTML without triggering the browser to make requests to the server for referenced content inside the evaluated HTML? Thanks!

    Read the article

< Previous Page | 83 84 85 86 87 88 89 90 91 92 93 94  | Next Page >