467,080 Members | 937 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,080 developers. It's quick & easy.

need a view with "order by"


I have 2 tables and am displaying data in a single table on a web page
from both tables. Most of the data that I'm displaying is in table 2 but
some is in table 1 (lastname, firstname). I'm using "order by" to allow
sorting table 2 using hyperlinks, but I haven't figured out how to allow
sorting the "view" based on the lastname/firstname from table 1. The 2
tables are linked by a primary key. "Client_id" is a primary key in
table 1 and is a foreign key in table 2.

Is there a way to sort a view of 2 tables? I'd like to be able to sort
on lastnames from table 1 and then have the view show the correct data
from table 2 (get table 2 to display by last name).

thanks,
Jim

Jul 20 '05 #1
  • viewed: 1373
Share:
2 Replies
James Johnson wrote:
Is there a way to sort a view of 2 tables? I'd like to be able to sort
on lastnames from table 1 and then have the view show the correct data
from table 2 (get table 2 to display by last name).


Does this do what you want?

SELECT table2.*
FROM table1 INNER JOIN table2 USING (Client_id)
ORDER BY table1.lastname, table1.firstname

Regards,
Bill K.
Jul 20 '05 #2
On Tue, 04 Jan 2005 12:13:25 -0800, Bill Karwin <bi**@karwin.com> wrote:
James Johnson wrote:
Is there a way to sort a view of 2 tables? I'd like to be able to sort
on lastnames from table 1 and then have the view show the correct data
from table 2 (get table 2 to display by last name).


Does this do what you want?

SELECT table2.*
FROM table1 INNER JOIN table2 USING (Client_id)
ORDER BY table1.lastname, table1.firstname

Regards,
Bill K.


Thanks for your suggestion. That works perfectly.

Jim

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

23 posts views Thread by ian justice | last post: by
1 post views Thread by Simon Wigzell | last post: by
4 posts views Thread by Josué Maldonado | last post: by
9 posts views Thread by Frederik | last post: by
2 posts views Thread by Richard Hollenbeck | last post: by
3 posts views Thread by =?Utf-8?B?VmFuZXNzYQ==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.