SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
Thread: gettin a little complex here...
-
May 14, 2001, 18:15 #1
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey, before I asked how to get results alphabeticly, and how to limit the amount of results I get by 20.
Now how do I use these together?
I understand this is probaly a lenghty processso if you dont really want to type it all out, at least redirect me to a site that can teach me this?
the list must first be sort from A-Z then pick 20 results from it?
thanx
Ryan Lahay
-
May 14, 2001, 19:53 #2
- Join Date
- Mar 2001
- Location
- Washington State
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
is this from a SQL friendly database? if so, something similar to the following will be in (at the end of) your query :
ORDER BY sometablename ASC LIMIT 20
-
May 14, 2001, 20:29 #3
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
yes it is
so it owuld be like..
$sql= "SELECT * FROM list ORDER BY sometablename ASC LIMIT 20";
now lets say i have another collum of entries... and they contain values that are something like
red
blue
green
red
green
green
green
red
that collum was maybe.. er.. color ?
now lets say i hve another collom with something like
a
v
g
a
f
d
h
a
called letter
k... now I want to have a statement that will select only the color stored in $variable and then from those results list htem alphabeticly based on the letter collum, and for an extra twist, only have a max of 20
-
May 14, 2001, 21:02 #4
- Join Date
- Jul 1999
- Location
- Chicago
- Posts
- 2,629
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
$sql= "SELECT * FROM list ORDER BY letter DESC LIMIT 20";
You would replace 'sometablename' with 'letter', since that is the column you want to order your results by.
BTW--I think it would be DESC instead of ASC. ASC would be backward-alphabetically.
-
May 14, 2001, 22:11 #5
- Join Date
- Mar 2001
- Location
- Washington State
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
May 14, 2001, 22:17 #6
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
list is the name of the table that has all these values..
does that replace sometablename ?
Im pretty sure it does.. just double checkin
-
May 14, 2001, 22:19 #7
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
list is the name of the table that has all these values..
does that replace sometablename ?
Im pretty sure it does.. just double checkin
or is it supposed to be the collum that I want teh data to be sorted alphabeticly buy ..which in this case is "letter"
-
May 14, 2001, 22:27 #8
- Join Date
- Mar 2001
- Location
- Washington State
- Posts
- 70
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
sounds like you want sometablename to be 'letter'. In fact, whenever you see me writing sometablename pretend i wrote somecolumnname :-) oops!
-
May 14, 2001, 22:33 #9
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanx
been a great help
-
May 15, 2001, 18:22 #10
- Join Date
- Apr 2001
- Location
- BC, Canada
- Posts
- 630
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
how about selecting everything that says an exact value (like "cow") from 3 different collums.. lets say the three are called "col1" "col2" "col3"
after getting those results, alphabeticly sort them by another collum called "name"
Do i just put three WHERE statement things in it?Last edited by slighltywhacked; May 16, 2001 at 15:56.
Bookmarks