[Klug-general] Mysql subqueries in PHP
david.halliday at gmail.com
Wed Jun 29 09:18:21 UTC 2011
Not 100% sure on the PHP side. I know that older versions of MySQL (and this
could be what the PHP is thinking of) didn't have good sub query support.
This could also be a case of what database you are connected to/have access
to (I'm presuming that mahara is a different DB)
In some systems this LEFT OUTER JOIN method can be a lot more efficient than
a NOT IN
You still get everything from table 1 that doesn't have an instance in table
FROM usr AS u
LEFT OUTER JOIN mahara.group_member AS gm
ON u.id = gm.member
WHERE gm.member IS NULL;
This doesn't take care of the requirement on table 2 having a condition on
it. I am going to play with some IF/CASE statements and get back to you.
On 29 June 2011 09:13, Dan Attwood <danattwood at gmail.com> wrote:
> I know that isn't strictly Linux but here we go;
> I have the following mysql query:
> SELECT * FROM usr WHERE usr.id NOT IN (SELECT DISTINCT member FROM
> mahara.group_member WHERE mahara.group_member.group='10')
> This selects all users in the usr table that don't have entry for group 10
> in the group_member table
> The query works as expected when run in mysql workbench
> However when I run it in a php script it only run the first part, so does
> select * from usr
> Has anyone come across this before and have any idea of a fix?
> Kent mailing list
> Kent at mailman.lug.org.uk
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Kent