Re: query help

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: volunteer(at)spatiallink(dot)org
Cc: pgsql-general(at)postgresql(dot)org, alex(at)purefiction(dot)net, rdeleonp(at)gmail(dot)com
Subject: Re: query help
Date: 2007-09-13 15:44:34
Message-ID: 46E95AE2.6020304@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

volunteer(at)spatiallink(dot)org wrote:
> hello
> i add more column not row for new user. i want all "last like 'J%'".
> http://www.nabble.com/an-other-provokative-question---tf4394285.html
> sincerely
> siva

You add a new _column_ for each user?!? That is hideously broken in so
many ways. It makes the trivially easy query you are trying to write
rather complicated, prevents you from being able to use indexes for
either constraints or performance and requires you to change your table
definition anytime you add data. And that's just for starters.

Fix your table so it has three columns (id, first, last). Then your
query is as easy as:
select id,first,last from foo where last like 'J%';

Cheers,
Steve

In response to

Browse pgsql-general by date

  From Date Subject
Next Message volunteer 2007-09-13 15:46:41 Re: query help
Previous Message Alexander Staubo 2007-09-13 15:38:04 Re: query help