Re: Select Command

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org, Adrian Klaver <aklaver(at)comcast(dot)net>
Cc: Bob Pawley <rjpawley(at)shaw(dot)ca>
Subject: Re: Select Command
Date: 2007-10-22 15:05:11
Message-ID: 604521.94289.qm@web31815.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

--- On Sun, 10/21/07, Adrian Klaver <aklaver(at)comcast(dot)net> 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';

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Valerie Cole 2007-10-22 15:08:46 Re: Question regarding Hibernate ORDER BY issue
Previous Message Trevor Talbot 2007-10-22 15:04:03 Re: 8.2.3: Server crashes on Windows using Eclipse/Junit