query help

Started by Nonameover 18 years ago9 messagesgeneral
Jump to latest
#1Noname
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

#2Alexander Staubo
alex@purefiction.net
In reply to: Noname (#1)
Re: query help

On 9/13/07, volunteer@spatiallink.org <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.

#3Rodrigo De León
rdeleonp@gmail.com
In reply to: Noname (#1)
Re: query help

On 9/13/07, volunteer@spatiallink.org <volunteer@spatiallink.org> wrote:

query is??

http://www.w3schools.com/sql/default.asp

#4Noname
volunteer@spatiallink.org
In reply to: Rodrigo De León (#3)
Re: query help

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" <alex@purefiction.net>
Date: Thu, September 13, 2007 11:17 am
To: "volunteer@spatiallink.org" <volunteer@spatiallink.org>
Cc: pgsql-general@postgresql.org

On 9/13/07, volunteer@spatiallink.org <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/

#5Alexander Staubo
alex@purefiction.net
In reply to: Noname (#4)
Re: query help

On 9/13/07, volunteer@spatiallink.org <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.

#6Steve Crawford
scrawford@pinpointresearch.com
In reply to: Noname (#4)
Re: query help

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

#7Noname
volunteer@spatiallink.org
In reply to: Steve Crawford (#6)
Re: query help

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" <alex@purefiction.net>
Date: Thu, September 13, 2007 11:38 am
To: "volunteer@spatiallink.org" <volunteer@spatiallink.org>
Cc: pgsql-general@postgresql.org

On 9/13/07, volunteer@spatiallink.org <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

#8brian
brian@zijn-digital.com
In reply to: Noname (#4)
Re: query help

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

#9Noname
volunteer@spatiallink.org
In reply to: brian (#8)
Re: query help

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 <alex@purefiction.net>
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" <alex@purefiction.net>
Date: Thu, September 13, 2007 11:38 am
To: "volunteer@spatiallink.org" <volunteer@spatiallink.org>
Cc: pgsql-general@postgresql.org

On 9/13/07, volunteer@spatiallink.org <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.