Subject | Re: [IBO] Singleton select error |
---|---|
Author | Lester Caine |
Post date | 2005-06-06T06:40:51Z |
Daniel R. Jimenez wrote:
I presume that that DISTINCT should not actually be necessary - there
should only be one UGL_USERS_ID for each user in a UGL_UG_ID ( Primary
key on USERS_GROUP_LINK should be 'UGL_UG_ID, UGL_USERS_ID' )
What happens if you change the last lines to -
WHERE USERS_GROUP_LINK.UGL_UG_ID=2
I am probably wrong, but I tend to do this sort of query with a sub select
SELECT
USERS_GROUP_LINK.UGL_USERS_ID,
( SELECT USERS_NAME FROM USERS
WHERE USERS_ID = USERS_GROUP_LINK.UGL_USERS_ID ) AS USERS_NAME
FROM USERS_GROUP_LINK
WHERE USERS_GROUP_LINK.UGL_UG_ID=2
ORDER BY 2
( That just gives you alphabetical order on the names )
That way you know exactly what you are getting, and from where
I think that you have created an INNER JOIN that requires the USERS_ID
simply to identify the records, and then IBO needs that visible to allow
it to update buffers.
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
> If I modify the SQL to be:From that I would assume that USERS_ID is the primary key on USERS?
>
> SELECT DISTINCT
> USERS_GROUP_LINK.UGL_USERS_ID,
> USERS.USERS_NAME,
> USERS.USERS_ID // This is the only difference to the original SQL
> FROM
> USERS_GROUP_LINK
> INNER JOIN
> USERS
> ON
> USERS_GROUP_LINK.UGL_USERS_ID=USERS.USERS_ID
> AND
> USERS_GROUP_LINK.UGL_UG_ID=2
>
> The problem goes away. Why????
I presume that that DISTINCT should not actually be necessary - there
should only be one UGL_USERS_ID for each user in a UGL_UG_ID ( Primary
key on USERS_GROUP_LINK should be 'UGL_UG_ID, UGL_USERS_ID' )
What happens if you change the last lines to -
WHERE USERS_GROUP_LINK.UGL_UG_ID=2
I am probably wrong, but I tend to do this sort of query with a sub select
SELECT
USERS_GROUP_LINK.UGL_USERS_ID,
( SELECT USERS_NAME FROM USERS
WHERE USERS_ID = USERS_GROUP_LINK.UGL_USERS_ID ) AS USERS_NAME
FROM USERS_GROUP_LINK
WHERE USERS_GROUP_LINK.UGL_UG_ID=2
ORDER BY 2
( That just gives you alphabetical order on the names )
That way you know exactly what you are getting, and from where
I think that you have created an INNER JOIN that requires the USERS_ID
simply to identify the records, and then IBO needs that visible to allow
it to update buffers.
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services