Search Postgresql Archives

Re: Select Command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--- On Sun, 10/21/07, Adrian Klaver <aklaver@xxxxxxxxxxx> wrote:
> > I have a column with data structured as follows.
> >
> > 32TT - 0002
> > 32LT- 0004
> > 32PT-0005
> >
> > Is there a way of selecting all of the rows containing
> LT in that column??
> >
> > I have attempted variations of ' *LT* ' with
> out success.

I set up my table structure a little differently:

CREATE TABLE loops (
 area  INTEGER CHECK( AREA BETWEEN 1 AND 99),
 process_code VARCHAR(1)  CHECK ( process_code ~ [A-Z]),
 loop_nbr INTEGER CHECK( loop_nbr BETWEEN 1 AND 9999),
 suffix VARCHAR(1) CHECK ( suffix ~ [A-Z] ),
 loop_work_scope VARCHAR CHECK ( loop_work_scope IN ( 'NEW','REUSE','DEMO'),
PRIMARY KEY ( area, process_code, loop_nbr, suffix, loop_work_scope)
);

CREATE TABLE tags (
  area  INTEGER CHECK( AREA BETWEEN 1 AND 99),
 process_code VARCHAR(1)  CHECK ( process_code ~ [A-Z]),
 loop_nbr INTEGER CHECK( loop_nbr BETWEEN 1 AND 9999),
 suffix VARCHAR(1) CHECK ( suffix ~ [A-Z] ),
 loop_work_scope VARCHAR CHECK ( loop_work_scope IN ( 'NEW','REUSE','DEMO'),
Foriegn KEY ( area, process_code, loop_nbr, suffix, work_scope) 
REFERENCES ( Loops.area, Loops.process_code, Loops, Loop_nbr, Loops_suffix, Loops.work_scope ),
 Instrument_code VARCHAR(4),
 Instrument_suffix varchar(1) check ( suffix ~ [A-Z])
 Instrument_work_scope varchar check (insturment_work_scope in ( 'NEW','REUSE','DEMO'),
Primary KEY ( area, Instrument_code, loop_nbr, instrument_suffix, Instrument_work_scope ) );

SELECT area || insturment_code || to_char( loop_nbr, '0000' ) || instrument_suffix AS tag
  FROM Tags
 WHERE instrument_code = 'LT'
     AND instrument_work_scope = 'NEW';

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux