query help
query help
От:
volunteer@spatiallink.org
Дата:
hello table is +-------+-------+------+-------+ | id | one | two | three | +-------+-------+------+-------+ | first | Jack | Jill | Mary | | last | Ja | Ji | Ma | +-------+-------+------+-------+ result is +----+-------+-------+ | id | one | two | +----+-------+-------+ | first | Jack | Jill | | last | Ja | Ji | +----+-------+-------+ query is?? sincerely siva
Re: query help
От:
"Alexander Staubo" <alex@purefiction.net>
Дата:
On 9/13/07, volunteer@spatiallink.org wrote: > hello > > table is > +-------+-------+------+-------+ > | id | one | two | three | > +-------+-------+------+-------+ > | first | Jack | Jill | Mary | > | last | Ja | Ji | Ma | > +-------+-------+------+-------+ > > result is > +----+-------+-------+ > | id | one | two | > +----+-------+-------+ > | first | Jack | Jill | > | last | Ja | Ji | > +----+-------+-------+ > > query is?? Unless I am missing something crucial, this is SQL 101: select id, one, two from foo; Alexander.
Re: query help
От:
"Rodrigo De León" <rdeleonp@gmail.com>
Дата:
On 9/13/07, volunteer@spatiallink.org wrote: > query is?? http://www.w3schools.com/sql/default.asp
Re: query help
От:
volunteer@spatiallink.org
Дата:
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 -------- Original Message -------- Subject: Re: [GENERAL] query help From: "Alexander Staubo" Date: Thu, September 13, 2007 11:17 am To: "volunteer@spatiallink.org" Cc: pgsql-general@postgresql.org On 9/13/07, volunteer@spatiallink.org wrote: > hello > > table is > +-------+-------+------+-------+ > | id | one | two | three | > +-------+-------+------+-------+ > | first | Jack | Jill | Mary | > | last | Ja | Ji | Ma | > +-------+-------+------+-------+ > > result is > +----+-------+-------+ > | id | one | two | > +----+-------+-------+ > | first | Jack | Jill | > | last | Ja | Ji | > +----+-------+-------+ > > query is?? Unless I am missing something crucial, this is SQL 101: select id, one, two from foo; Alexander. ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org/
Re: query help
От:
"Alexander Staubo" <alex@purefiction.net>
Дата:
On 9/13/07, volunteer@spatiallink.org wrote: > 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 Sorry, but the only difference between your table example and your result example was the absence, in the results, of one of the columns. If you want to constrain by some attribute, then you have to tell us that. I recommend that you buy a book on SQL. Lastly, I don't see what this has to do with the "provokative question" thread. Alexander.
Re: query help
От:
Steve Crawford <scrawford@pinpointresearch.com>
Дата:
volunteer@spatiallink.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
Re: query help
От:
volunteer@spatiallink.org
Дата:
many apologees. right link http://archives.postgresql.org/pgsql-general/2007-09/msg00607.php i flip row to column if ok. but howto query?? sincerely siva -------- Original Message -------- Subject: Re: [GENERAL] query help From: "Alexander Staubo" Date: Thu, September 13, 2007 11:38 am To: "volunteer@spatiallink.org" Cc: pgsql-general@postgresql.org On 9/13/07, volunteer@spatiallink.org wrote: > 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 Sorry, but the only difference between your table example and your result example was the absence, in the results, of one of the columns. If you want to constrain by some attribute, then you have to tell us that. I recommend that you buy a book on SQL. Lastly, I don't see what this has to do with the "provokative question" thread. Alexander. ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster
Re: query help
От:
brian <brian@zijn-digital.com>
Дата:
volunteer@spatiallink.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
Re: query help
От:
volunteer@spatiallink.org
Дата:
can u refer to row?? howto select * from table where row(#2) like 'J%'?? i wanted to test column storing but not ok as no row refer name/id. many thank yous sincerely siva -------- Original Message -------- Subject: Re: [GENERAL] query help From: volunteer@spatiallink.org Date: Thu, September 13, 2007 11:46 am To: Alexander Staubo Cc: pgsql-general@postgresql.org many apologees. right link http://archives.postgresql.org/pgsql-general/2007-09/msg00607.php i flip row to column if ok. but howto query?? sincerely siva -------- Original Message -------- Subject: Re: [GENERAL] query help From: "Alexander Staubo" Date: Thu, September 13, 2007 11:38 am To: "volunteer@spatiallink.org" Cc: pgsql-general@postgresql.org On 9/13/07, volunteer@spatiallink.org wrote: > 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 Sorry, but the only difference between your table example and your result example was the absence, in the results, of one of the columns. If you want to constrain by some attribute, then you have to tell us that. I recommend that you buy a book on SQL. Lastly, I don't see what this has to do with the "provokative question" thread.