![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Is there a way I need only select the rows until the customerid ? eg. SELECT * FROM table UNTIL customerId = 22 ORDER BY price DESC with that I do not need to get all the data from the table. |
#3
| |||
| |||
|
|
Is there a way I need only select the rows until the customerid ? eg. SELECT * FROM table UNTIL customerId = 22 ORDER BY price DESC with that I do not need to get all the data from the table. SELECT <field you need> FROM table WHERE custumerId=22; ?? |
#4
| |||
| |||
|
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 08/02/10 11:08, nemaC wrote: Is there a way I need only select the rows until the customerid ? eg. SELECT * FROM table UNTIL customerId = 22 ORDER BY price DESC with that I do not need to get all the data from the table. SELECT <field you need> FROM table WHERE custumerId=22; *?? No. I get the possition from counting the whole result table manually eg. $i=1; foreach($result as $entry) { * * $newArray[$entry['customerId']] = $i; * * $i++; } The possition is not stored in the database, and changes everytime you alter the "order by" regards, johannes keßler -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iEYEARECAAYFAktv43gACgkQE++2Zdc7EtdmbACgk3K05HRH6l c4up1MqyMdOEbp WoMAn0AQp26uEFIKkHFP/hAAa289dJCA =wYdu -----END PGP SIGNATURE----- |
#5
| |||
| |||
|
|
On 8 Feb, 10:12, Johannes Keßler <m... (AT) bananas-playground (DOT) net> wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 08/02/10 11:08, nemaC wrote: Is there a way I need only select the rows until the customerid ? eg. SELECT * FROM table UNTIL customerId = 22 ORDER BY price DESC with that I do not need to get all the data from the table. SELECT <field you need> FROM table WHERE custumerId=22; Â*?? No. I get the possition from counting the whole result table manually eg. $i=1; foreach($result as $entry) { Â* Â* $newArray[$entry['customerId']] = $i; Â* Â* $i++; } The possition is not stored in the database, and changes everytime you alter the "order by" regards, johannes keßler -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (GNU/Linux) iEYEARECAAYFAktv43gACgkQE++2Zdc7EtdmbACgk3K05HRH6l c4up1MqyMdOEbp WoMAn0AQp26uEFIKkHFP/hAAa289dJCA =wYdu -----END PGP SIGNATURE----- I really don't understand what you are after. As you point out, there is no such thing as a "position" of a row in a table. Maybe if you told us what you ultimately want to achieve by this? |
#6
| |||
| |||
|
|
my "problem": (Those are fake data) A table with a lot of rows. To decide at which possition a row is located compared to others, I currently make a select with an order criterion. |
#7
| |||
| |||
|
|
On 8 Feb, 10:12, Johannes Keßler <m... (AT) bananas-playground (DOT) net> wrote: On 08/02/10 11:08, nemaC wrote: Is there a way I need only select the rows until the customerid ? eg. SELECT * FROM table UNTIL customerId = 22 ORDER BY price DESC with that I do not need to get all the data from the table. SELECT <field you need> FROM table WHERE custumerId=22; ?? No. I get the possition from counting the whole result table manually eg. $i=1; foreach($result as $entry) { $newArray[$entry['customerId']] = $i; $i++; } The possition is not stored in the database, and changes everytime you alter the "order by" regards, johannes keßler I really don't understand what you are after. As you point out, there is no such thing as a "position" of a row in a table. Maybe if you told us what you ultimately want to achieve by this? |
#8
| |||
| |||
|
|
In article <hkom9v$s27$03$1 (AT) news (DOT) t-online.com>, =?UTF-8?B?Sm9oYW5uZXMgS2XDn2xlcg==?= <mail (AT) bananas-playground (DOT) net> wrote: my "problem": (Those are fake data) A table with a lot of rows. To decide at which possition a row is located compared to others, I currently make a select with an order criterion. The fact that you think you need this is suggestive of a design flaw. |
#9
| |||
| |||
|
|
On 08/02/10 13:11, Doug Miller wrote: In article <hkom9v$s27$03$1 (AT) news (DOT) t-online.com>, =?UTF-8?B?Sm9oYW5uZXMgS2XDn2xlcg==?= <mail (AT) bananas-playground (DOT) net> wrote: my "problem": (Those are fake data) A table with a lot of rows. To decide at which possition a row is located compared to others, I currently make a select with an order criterion. The fact that you think you need this is suggestive of a design flaw. This could also be the case, but the possition changes everytime you change the ORDER BY. This way you can't save the possition in the table |
#10
| |||
| |||
|
|
So my question is if I can create a query which just does this without getting all the data. I hope it is more clear now. But english is not my primary language. |
|
row_pos | name | +---------+----------+ 1 | Fluffy | 2 | Claws | 3 | Buffy | 4 | Fang | 5 | Bowser | 6 | Chirpy | 7 | Whistler | 8 | Slim | 9 | Puffball | +---------+----------+ |
![]() |
| Thread Tools | |
| Display Modes | |
| |