Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: match value against value in other table

  1. #11
    Join Date
    Apr 2006
    Location
    Amsterdam
    Posts
    350
    Thanks
    20
    Thanked 11 Times in 11 Posts

    Default

    Quote Originally Posted by Warren Ashcroft View Post
    I don't see the valid column in the where clause?
    Your right, the active and valid names got mixed up. Should be:
    Code:
    UPDATE Table1 set valid = 'false'
    WHERE valid = 'true' AND code NOT IN
    (SELECT code FROM Table2)

  2. #12
    Join Date
    Feb 2004
    Posts
    4,877
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Is the valid column a varchar column? Normally those columns should be bit columns.

    WHERE valid = 1

    or

    WHERE valid = true (notice no string quotes)

    In any case, an index can't do any harm.
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #13
    Join Date
    Jun 2005
    Location
    London
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by Rappie View Post

    Adding indexes really helped too. One more question though, should I index the `valid` colum as well? Because of the use in the WHERE clause.
    Was that a typo and you really mean because of the use of Valid in the UPDATE clause ? If so, I'd say no - dont index it - it'll slow down your query if anything.

  4. #14
    Join Date
    Jun 2005
    Location
    London
    Posts
    24
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default

    Whoops - just noticed the last 2 posts on this thread.
    Seem to recall from somewhere that indexing field that only holds a couple of values isnt worth indexing, but as Warren says it probably wont do any harm in this case

  5. #15
    Join Date
    Jan 2006
    Posts
    419
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    Adding indexes will speed up queries significant but does add over head as when inserting / updating data then data needs updating in both the table and index. The overhead will be neglible in comparison to the improvements in selecting data.

    You need to analyse the queries that your will be running to determine where you need to put indexes.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. One query table
    By Rappie in forum MySQL
    Replies: 2
    Last Post: 17th March 2008, 11:03 PM
  2. Multiple Table Query
    By spire128 in forum MSSQL
    Replies: 6
    Last Post: 20th October 2006, 05:21 PM
  3. Embed Pivot Table
    By carlosgilf in forum ASP.NET
    Replies: 0
    Last Post: 8th September 2006, 04:47 PM
  4. Table-less design, css & XHTML
    By JohnnyW in forum Website and Graphic Design
    Replies: 2
    Last Post: 22nd December 2005, 01:06 PM
  5. Table Corner Rounding
    By Breaks in forum Development Support
    Replies: 8
    Last Post: 2nd November 2005, 10:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •