Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 32569 invoked from network); 17 Mar 2006 14:14:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Mar 2006 14:14:28 -0000 Received: (qmail 29577 invoked by uid 500); 17 Mar 2006 14:14:27 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 29530 invoked by uid 500); 17 Mar 2006 14:14:26 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 29519 invoked by uid 99); 17 Mar 2006 14:14:26 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Mar 2006 06:14:26 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [212.74.114.38] (HELO mk-smarthost-2.mail.uk.tiscali.com) (212.74.114.38) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 17 Mar 2006 06:14:24 -0800 Received: from 88-105-48-114.dynamic.dsl.as9105.com (HELO mk-smarthost-8.mail.uk.tiscali.com) ([88.105.48.114]) by mk-smarthost-2.mail.uk.tiscali.com with ESMTP; 17 Mar 2006 14:13:54 +0000 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AY8CAORLGkSHayw Received: from 88-105-48-114.dynamic.dsl.as9105.com ([88.105.48.114]:10083 helo=[192.168.11.128]) by mk-smarthost-8.mail.uk.tiscali.com with esmtp (Exim 4.30) id 1FKFi6-000JGK-3e for derby-user@db.apache.org; Fri, 17 Mar 2006 14:13:53 +0000 Message-ID: <441AC40C.5000808@brighton.ac.uk> Date: Fri, 17 Mar 2006 14:13:32 +0000 From: John English Organization: University of Brighton User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derby Discussion Subject: Difference between view and select statement Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N I have a table of users, one of which has '' (empty string) as the username. I issue the following select statement: SELECT NameFormat(surname,initials) AS name, users.username AS link, email, allowance, CASE WHEN passwords.username IS NULL THEN '' ELSE 'Y' END AS local, surname, initials FROM users LEFT OUTER JOIN passwords ON users.username=passwords.username WHERE users.username<>''; This works fine, listing 171 users (all except the one with the empty string as the username). Then I try making this a view: CREATE VIEW user_list AS [the same select statement as above]; Now when I do "SELECT * FROM user_list" I get 172 results, and this includes the one with the empty string as its name. Anyone got any ideas why this should be so? The only way to get the expected answer is to say SELECT * FROM user_list WHERE link<>'', which seems a bit perverse to me... ---------------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je School of Computing & MIS | "Those who don't know their history University of Brighton | are condemned to relive it" (Santayana) ----------------------------------------------------------------------