Home

ttamniwdoog.com

Login

Website Magazine

Tags in Blog Vocab

admin Advanced Search Operators Block blog calendar ColorZilla command line cron Dell Precision 340 Derived Tables dig Drupal FireBug Firefox add-ons Google Google Analytics Joomla jos_users KeeneYPN linux LOCATE lynx MD5 mobile MX records MySQL mySQL table OPHCrack live CD Outlook Password php phpMyAdmin recovery salt single quotes SQL SQL Server tar Taxonomy Technorati Temp Tables tool ubercart Untar Web Development Toolbar wget Windows Windows Vista Windows XP YSlow
more tags

Navigation

  • Contact

Artisteer - Drupal Theme Generator

Find records in one table but missing from another

Posted Fri, 11/14/2008 - 09:45 by matt.goodwin

Finding records in one table not present in another table you could use either of these two methods.
For example, you want to see all of the registered users who have yet to place an order.

SELECT users.*
FROM users
LEFT JOIN uc_orders ON users.uid = uc_orders.uid
WHERE uc_orders.uid IS NULL

Or if joins are not supported you could use the slower method


SELECT users.*
FROM users
WHERE users.uid NOT IN (SELECT uid FROM uc_orders)

  • Printer-friendly version
  • matt.goodwin's blog
  • share
  • Send to friend
Theme provided by Acquia, Inc. under GPL license from TopNotchThemes Drupal themes