|
-
March 23rd, 2010, 03:15 PM
#1
[RESOLVED] SQL: Secondary Sorting
I've got an issue right now, where I'm using two different tables, that share a primary key.
What I currently have is,
a Table called Application, which holds:
Code:
ApplicationID: (primary key)
Name:
Description
a table called Favorite, which holds an ID, application ID (foreign), computer login id.
Code:
ID:
ApplicationID: (foreign key)
Enumber: (( Environment.Username))
-- what I am doing is on an ASP.NET page, upon click I'm insert/deleting/selecting content from these two tables - I can add just fine, delete just fine, but I'd like to generate a query SORTING my gridview such that:
my favorites are on the top, and the nonfavorites are on bottom, and sort based on name in ADDITION.
so you could imagine....
"starred" items being on top, sorted by name, and right below, non-star sorted by name.
I've tried an assortment of joins, but can't seem to get it right.
Code:
SELECT Favorite.ID, Application.Name
FROM Application LEFT OUTER JOIN Favorite ON (what should go here??)
WHERE Favorite.Enumber = '<whatever user>'
ORDER BY ????, ????
Thanks for any help I can get!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|