MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Bill Marrs Date:November 26 2002 6:52pm
Subject: join with OR and LIMIT fails to return result
View as plain text  
>Description:
	join with OR and LIMIT fails to return result
>How-To-Repeat:

This query fails to return a result:

mysql> SELECT Subscriptions.UID FROM Subscriptions, Accounts WHERE 
Accounts.UID = Subscriptions.User  AND (Accounts.Email = 'bill' OR 
Accounts.UName = 'bill') ORDER BY Subscriptions.Created DESC limit 1;
Empty set (0.02 sec)

But, if I remove one of the parenthesized OR tokens, it works:

mysql> SELECT Subscriptions.UID FROM Subscriptions, Accounts WHERE 
Accounts.UID = Subscriptions.User  AND Accounts.UName = 'bill' ORDER BY 
Subscriptions.Created DESC limit 1;
+-----+
| UID |
+-----+
| 255 |
+-----+
1 row in set (0.00 sec)

Or, if I remove the LIMIT, it works:

mysql> SELECT Subscriptions.UID FROM Subscriptions, Accounts WHERE 
Accounts.UID = Subscriptions.User  AND (Accounts.Email = 'bill' OR 
Accounts.UName = 'bill') ORDER BY Subscriptions.Created DESC;
+-----+
| UID |
+-----+
| 255 |
+-----+
1 row in set (0.11 sec

I've already worked around this, I'm just letting you guys know.


>Fix:
	

>Submitter-Id:	<submitter ID>
>Originator:	Bill Marrs
>Organization:
 
>MySQL support: [none | licence | email support | extended email support ]
>Synopsis:	join with OR and LIMIT fails to return result
>Severity:	
>Priority:	
>Category:	mysql
>Class:		
>Release:	mysql-4.0.4-beta (Official MySQL RPM)
>Server: /usr/bin/mysqladmin  Ver 8.37 Distrib 4.0.4-beta, for pc-linux-gnu on i686
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version		4.0.4-beta-log
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			3 hours 46 min 41 sec

Threads: 25  Questions: 493984  Slow queries: 28  Opens: 1332  Flush tables: 1  Open
tables: 64  Queries per second avg: 36.320
>Environment:
	
System: Linux KenyonHill.com 2.4.18 #2 SMP Tue Apr 9 22:46:52 EDT 2002 i686 unknown
Architecture: i686

Some paths:  /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc
GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)
Compilation info: CC='gcc'  CFLAGS='-O6 -fno-omit-frame-pointer -mpentium'  CXX='gcc' 
CXXFLAGS='-O6 -fno-omit-frame-pointer 	          -felide-constructors -fno-exceptions
-fno-rtti -mpentium'  LDFLAGS=''
LIBC: 
lrwxrwxrwx    1 root     root           13 Nov 12 08:51 /lib/libc.so.6 -> libc-2.2.4.so
-rwxr-xr-x    1 root     root      5737154 Oct 10 12:50 /lib/libc-2.2.4.so
-rw-r--r--    1 root     root     27338282 Oct 10 12:48 /usr/lib/libc.a
-rw-r--r--    1 root     root          178 Oct 10 12:48 /usr/lib/libc.so
Configure command: ./configure --disable-shared --with-mysqld-ldflags=-all-static
--with-client-ldflags=-all-static --without-berkeley-db --with-innodb --without-vio
--without-openssl --enable-assembler --enable-local-infile --with-mysqld-user=mysql
--with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/ --with-extra-charsets=complex
--exec-prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share
--localstatedir=/var/lib/mysql --infodir=/usr/share/info --includedir=/usr/include
--mandir=/usr/share/man --with-embedded-server --enable-thread-safe-client
'--with-comment=Official MySQL RPM' CC=gcc 'CFLAGS=-O6 -fno-omit-frame-pointer -mpentium'
'CXXFLAGS=-O6 -fno-omit-frame-pointer 	          -felide-constructors -fno-exceptions
-fno-rtti -mpentium' CXX=gcc

Thread
join with OR and LIMIT fails to return resultBill Marrs26 Nov
  • Re: join with OR and LIMIT fails to return resultJohn Ragan26 Nov
    • Re: join with OR and LIMIT fails to return resultJocelyn Fournier26 Nov