Re: union replacing values

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Steve Kass (skass_at_drew.edu)
Date: 02/26/05


Date: Sat, 26 Feb 2005 13:29:22 -0500

Try something like this:

select
  coalesce(
    (
      select conf_value from tab_user_conf
      where user_id = @userId
    )
  ,
    (
      select conf_value from tab_org_conf
      where org_id = @orgId
    )
  )

Steve Kass
Drew University

Henri wrote:

>Hello,
>
>I want to retrieve the preferences of a user.
>There are two table.
>The first one called tab_org_conf store key-value pairs indicating the
>default preferences of the organisation the user belongs to.
>The second one called tab_user_conf store key-value pairs indicating the
>preferences specific to the user.
>My problem is that I want that user's preferences override organisation's
>default preferences.
>For instance if there's conf_key: COLOR, conf_value: blue in tab_org_conf
>and conf_key: COLOR, conf_value: red in tab_user_conf
>I only want to get the last one as selected row and not the first one.
>I've tried UNION:
>
>SELECT
> conf_key,
> conf_value
>FROM
> tab_org_conf
>WHERE
> org_id = @orgId
>
>UNION
>
>SELECT
> conf_key,
> conf_value
>FROM
> tab_user_conf
>WHERE
> [user_id] = @userId
>
>but it returns both rows.
>How can I get tab_user_conf rows to override tab_org_conf rows when conf_key
>is the same?
>
>Thanks for your help.
>
>Henri
>
>
>
>
>



Relevant Pages

  • Re: union replacing values
    ... Henri wrote: ... > default preferences of the organisation the user belongs to. ... > I only want to get the last one as selected row and not the first one. ... > I've tried UNION: ...
    (microsoft.public.sqlserver.programming)
  • Re: union replacing values
    ... Henri ... > default preferences of the organisation the user belongs to. ... > I only want to get the last one as selected row and not the first one. ... > I've tried UNION: ...
    (microsoft.public.sqlserver.programming)
  • Re: Re-installing
    ... so wanted files and Preferences can be retrieved. ... stikk retrieve these files when reloading iPhoto and iTunes if needed. ... You can SAVE Prefernces and internet settings by setting this Option ... re-installs the OS and leaves all other files intact. ...
    (comp.sys.mac.system)
  • Re: Module for user preferences ~/. file
    ... I mean more of the retrieve really. ... I would like to store ... preferences in a file with a format like this: ... script would look for the file and automatically load in these ...
    (comp.lang.perl.misc)
  • Evolution and the filter
    ... Evolution leaves mail I've created on gmail.com, and doesn't retrieve it ... to my inbox. ... I've looked all over preferences and cannot find a setting ...
    (Fedora)