Re: query help

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: query help
Date: 2007-09-13 15:50:20
Message-ID: 46E95C3C.9060307@zijn-digital.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%'".

I get the feeling that the result as you've laid it out is not what we
all think it is. For example:

>>table is
>>+-------+-------+------+-------+
>>| id | one | two | three |
>>+-------+-------+------+-------+
>>| first | Jack | Jill | Mary |
>>| last | Ja | Ji | Ma |
>>+-------+-------+------+-------+

I took that to meant that you have columns 'id', 'one', two', three',
and that 'first' & 'last' are field values. However, it now seems that
'first' & 'last' are column names. If so, this makes no sense. I think
what you wanted to give us was:

+-------+-------+------+
| id | first | last |
+-------+-------+------+
| one | Jack | Ja |
| two | Jill | Ji |
| three | Mary | Ma |

result:

+-------+-------+------+
| id | first | last |
+-------+-------+------+
| one | Jack | Ja |
| two | Jill | Ji |

So, the query you want is, in fact:

SELECT * FROM your_table WHERE last LIKE ('J%');

If that's not working for you, it's perhaps because you have rows for
columns and columns for rows.

> http://www.nabble.com/an-other-provokative-question---tf4394285.html
> sincerely
> siva
>

What the heck does this have to do with anything?

Please don't top-post.

brian

In response to

Browse pgsql-general by date

  From Date Subject
Next Message volunteer 2007-09-13 16:31:17 Re: query help
Previous Message volunteer 2007-09-13 15:46:41 Re: query help