Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2

Thread: SQL help.

  1. #1
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    Well, this one is for transio, but if anyone else can help, I'll appreciate.

    I have two mysql tables (same db) with the following structure:

    T1
    id (int, auto_inc, primary key)
    order_id (varchar)

    T2
    OrderID (varchar)


    T2 does not have a primary key (I inhereted the database from a former programmer on staff). T1 is mine. OrderID is supposed to be in form 99999999, however, it is not strictly enforced. Some of them are like "9999999, old order id: 3333333" or "1234ABC3434343CCC" (paypal transaction ids) etc.

    Problem
    Select all "id"s for "order_id" from T1 where T1.order_id is NOT present in T2.OrderID.

    I am hoping that it is possible to do it within SQL without having to loop SQL queries via a PHP/Perl script.

    Thank.
    There and Back Again :Ogre:

  2.  

  3. #2
    Senior Member nsr81's Avatar
    Join Date
    Oct 2002
    Posts
    1,132
    Member #
    250
    Liked
    15 times
    One idea:

    Code:
    select t1.id
    FROM t1 INNER JOIN t2
    ON (t2.OrderID LIKE CONCAT('%',t1.order_id,'%') )
    However it is very slow. Takes about 10 secs before it spits out the first line of output.
    There and Back Again :Ogre:


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:31 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com