Re: [SQL] Left join?

2006-07-01 Thread Richard Broersma Jr
> In the following table, codsol, codate and codfec are foreign keys > referencing table func and I need some help to codify a SELECT command that > produces the following result set but instead of codsol, codate and codfec I > need the respectives names (column nome from table func). > > postgre

[SQL] Left join?

2006-07-01 Thread Carlos H. Reimer
Hi, In the following table, codsol, codate and codfec are foreign keys referencing table func and I need some help to codify a SELECT command that produces the following result set but instead of codsol, codate and codfec I need the respectives names (column nome from table func). postgres=# sel

Re: [SQL] Alternative to Select in table check constraint

2006-07-01 Thread Aaron Bono
This is more of an implementation option, but when I worry about what is active/inactive I put start/end dates on the tables.  Then you don't need active indicators.  You just look for the record where now() is >= start date and now() <= end date or end date is null.  You can even activate/deactiva

Re: [SQL] Alternative to Select in table check constraint

2006-07-01 Thread Rod Taylor
On Fri, 2006-06-30 at 18:41 -0700, Richard Broersma Jr wrote: > > > CHECK ( 1 = ALL ( SELECT COUNT(STATUS) > > > FROM BADGES > > > WHERE STATUS = 'A' > > > GROUP BY EMPNO)) > > > > From t

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Daniel CAUNE
> -Message d'origine- > De : Michael Glaesemann [mailto:[EMAIL PROTECTED] > Envoyé : samedi 1 juillet 2006 10:01 > À : Daniel CAUNE > Cc : pgsql-sql@postgresql.org > Objet : Re: [SQL] Constraint UNIQUE on a column not case sensitive > > > On Jul 1, 2006, at 22:47 , Daniel CAUNE wrote: >

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Jorge Godoy
Daniel CAUNE <[EMAIL PROTECTED]> writes: > Hi, > > I would like to find an efficient solution for adding/implementing a > constraint UNIQUE on a VARCHAR column not case sensitive: > > ALTER TABLE MyTable > ADD CONSTRAINT UNQ_MyTable_MyColumn > UNIQUE (lower(MyColumn)); -- invalid synt

Re: [SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Michael Glaesemann
On Jul 1, 2006, at 22:47 , Daniel CAUNE wrote: The idea is to have an index on that column, in a not case sensitive form, i.e. lower(MyColumn). I think you're really close. Try CREATE UNIQUE INDEX ci_mycolumn_idx ON mytable(lower(mycolumn)); Does that do what you're looking for? Michael G

[SQL] Constraint UNIQUE on a column not case sensitive

2006-07-01 Thread Daniel CAUNE
Hi, I would like to find an efficient solution for adding/implementing a constraint UNIQUE on a VARCHAR column not case sensitive: ALTER TABLE MyTable ADD CONSTRAINT UNQ_MyTable_MyColumn UNIQUE (lower(MyColumn)); -- invalid syntax The idea is to have an index on that column, in a n

Re: [SQL] Alternative to Select in table check constraint

2006-07-01 Thread Erik Jones
Richard Broersma Jr wrote: But now that I think about it, using the authors suggestion (if it actually worked), how would would it be possible to change the active status from one badge to another? Well, the check constraint as you wrote it requires that there always be a badge listed as act