473,407 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Ordering alphabetical in secondary select string



Does anyone have a suggestion how I can order a list with names in a
secondary select string.

The first string selects a number of locations where people work

From this string I get several id's form people (in the location table there
are no names but id's form the people table) that work on those locations

No I make another select to get the name form the people table using the id
I got before.

I would like to have the table ordered alphabetical by the name of the
people

Since the number op people is very long is will be to slow working the other
way around (first selecting people and then looking for the location)

Example:

Location 1 Name A

Name B

Name C

Location 3 Name D

Name E

Location 5 Name F

Location 2 Name G

Location 9 Name H

Location 7 Name I


Jul 17 '05 #1
4 2047
In article <40*********************@news.xs4all.nl>, R.G. Vervoort wrote:
Does anyone have a suggestion how I can order a list with names in a
secondary select string.

The first string selects a number of locations where people work
From this string I get several id's form people (in the location table there
are no names but id's form the people table) that work on those locations

No I make another select to get the name form the people table using the id
I got before.

I would like to have the table ordered alphabetical by the name of the
people
Since the number op people is very long is will be to slow working the other
way around (first selecting people and then looking for the location)


You might want to lookup what an INNER JOIN clause in a SQL query does.

SELECT *
FROM locations
INNER JOIN persons ON location.person_id=persons.person_id
ORDER BY location.name, person.name
--
http://home.mysth.be/~timvw
Jul 17 '05 #2

"R.G. Vervoort" <ro**********@royvervoort.nl> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:40*********************@news.xs4all.nl...


Does anyone have a suggestion how I can order a list with names in a
secondary select string.

The first string selects a number of locations where people work

From this string I get several id's form people (in the location table there are no names but id's form the people table) that work on those locations

No I make another select to get the name form the people table using the id I got before.

I would like to have the table ordered alphabetical by the name of the
people

Since the number op people is very long is will be to slow working the other way around (first selecting people and then looking for the location)

Example:

Location 1 Name A

Name B

Name C

Location 3 Name D

Name E

Location 5 Name F

Location 2 Name G

Location 9 Name H

Location 7 Name I



ORDER BY name ASC
Jul 17 '05 #3
it are different table and the first table does not contain names, onlu the
id form names.

Ordering ASC woll not work because it is not in the first query

thank for thinking with me anyway
"Dennis Biletsky" <uf***@ua.fm> schreef in bericht
news:c7***********@fortress.intercom.net.ua...

"R.G. Vervoort" <ro**********@royvervoort.nl> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:40*********************@news.xs4all.nl...


Does anyone have a suggestion how I can order a list with names in a
secondary select string.

The first string selects a number of locations where people work

From this string I get several id's form people (in the location table

there
are no names but id's form the people table) that work on those locations
No I make another select to get the name form the people table using the

id
I got before.

I would like to have the table ordered alphabetical by the name of the
people

Since the number op people is very long is will be to slow working the

other
way around (first selecting people and then looking for the location)

Example:

Location 1 Name A

Name B

Name C

Location 3 Name D

Name E

Location 5 Name F

Location 2 Name G

Location 9 Name H

Location 7 Name I



ORDER BY name ASC

Jul 17 '05 #4
Can you combine the queries?

Take the following example, given that there is a table post and there is a
table sprite. The post table contains several fields including a SPRITEID
field whos value corresponds directly the unique identifier of the same name
(SPRITEID) in the sprite table. The sprite table also contains a SPRITENAME
field that corresponds to the relative path of an image file.

Select post.POSTID, post.SPRITEID, sprite.SPRITENAME, sprite.SPRITEID
from post, sprite where post.SPRITEID = sprite.SPRITEID order by
sprite.SPRITENAME desc;

I have this table here and these are the first few results:

'post.POSTID',' post.SPRITEID', 'sprite.SPRITENAME',
'sprite.SPRITEID'
'245', '21', '"..\..\graphical
dump\esd\wizardjames.gif"', '21'
'252', '21', '"..\..\graphical
dump\esd\wizardjames.gif"', '21'
'188', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'216', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'220', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'228', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'232', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'233', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'238', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'242', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'243', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'248', '13', '"..\..\graphical
dump\esd\trevor.gif"', '13'
'183', '10', '"..\..\graphical
dump\esd\stew.gif"', '10'
'202', '10', '"..\..\graphical
dump\esd\stew.gif"', '10'
'208', '10', '"..\..\graphical
dump\esd\stew.gif"', '10'
'213', '10', '"..\..\graphical
dump\esd\stew.gif"', '10'

If you really want, look at the attatched txt file to see the full
results.

This is from a silly news poster/CMS type thing I wrote called ESDNews

I hope that helps you to work it out, if I'm understanding the question
correctly.

Joe Parish
"R.G. Vervoort" <ro**********@royvervoort.nl> wrote in message
news:40*********************@news.xs4all.nl...
it are different table and the first table does not contain names, onlu the id form names.

Ordering ASC woll not work because it is not in the first query

thank for thinking with me anyway
"Dennis Biletsky" <uf***@ua.fm> schreef in bericht
news:c7***********@fortress.intercom.net.ua...

"R.G. Vervoort" <ro**********@royvervoort.nl> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ
ÓÌÅÄÕÀÝÅÅ: news:40*********************@news.xs4all.nl...


Does anyone have a suggestion how I can order a list with names in a
secondary select string.

The first string selects a number of locations where people work

From this string I get several id's form people (in the location table

there
are no names but id's form the people table) that work on those locations
No I make another select to get the name form the people table using

the id
I got before.

I would like to have the table ordered alphabetical by the name of the
people

Since the number op people is very long is will be to slow working the

other
way around (first selecting people and then looking for the location)

Example:

Location 1 Name A

Name B

Name C

Location 3 Name D

Name E

Location 5 Name F

Location 2 Name G

Location 9 Name H

Location 7 Name I



ORDER BY name ASC


Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rim | last post by:
Hi, Is there a way to get any sort of introspection which would return the content of an instance *in the order they were declared or executed* as opposed to alphabetical order? Example: ...
4
by: prins.henrik | last post by:
I have the following xml data and would like to format it the following way with xslt: 1. I need to sort them after there last name (see my example below) 2. I only want to display the main...
5
by: Joe Molloy | last post by:
Hi Group, I have a task and I'm interested to see what ideas people have here for the best way of tackling it. I have a table of products. Each of the products is associated with a certain...
1
by: quirdan | last post by:
Hi, I am after some advice about which data structures I should use. I'm developing a program and I am at the point where all the strings are being generated and printed one by one with...
7
by: Ron Adam | last post by:
I have several applications where I want to sort lists in alphabetical order. Most examples of sorting usually sort on the ord() order of the character set as an approximation. But that is not...
3
by: eagerlearner | last post by:
I have the following code, which does not sort the list in alphabetical order, how can I sort everything in alphabetical order ? Before that, I want to ask, when an insertion occur, does it compare...
7
by: naoki | last post by:
Is it possible to sort a given container using two properties of the content? example: class Rectangle { int x, y; int width, height; }; std::list<Rectanglemy_list;
6
by: Jeff | last post by:
Lets say we have an array: $array='apples'; $array='orange'; $array='lemon'; echo $array; // orange Now, lets say we want to insert "grape", between apples and orange. How
2
by: pavanip | last post by:
Hi, I have a problem with binding data to dropdownlist from database in alphabetical order. My database contains some fields like All,Air,Airline,Books,Cars etc. There are 2 dropdown...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.