Search Postgresql Archives

Re: query help

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

 



volunteer@xxxxxxxxxxxxxxx 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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

              http://archives.postgresql.org/

[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