Just A Quick Question. Checked Many sites to no avail! I need stack help!
SQL Compact Edition!
have a query:
SELECT w.url
FROM Company c, Website w, Users u
WHERE w.companyID = c.companyID AND c.userID = u.userID AND u.userID = 23
ORDER BY w.url ASC;
I know its not the best query, but basically this returns a list of websites where the userID is 23. It returns a list like:
URL
-----------------
facebook.com
stackoverflow.com
google.com
...
etc
However i would like the add a column in the SELECT statement. so my results would appear like:
URL | ID
------------------|---------
facebook.com | 1
stackoverflow.com | 2
google.com | 3
... | ...
etc | onward
Ive tried many methods inc开发者_开发技巧luding sub queries and stuff but I'm using SQL CE! and is doesn't like running when I put an "=" when I select my columns.
I think its a simple solution but I CANT DO IT :(
Ive tried
SELECT w.url, count(*) as id
SELECT w.url, IDENTITY as id
and multiple variations of that!
EDIT: I want the id to increment from 1 to however many records there are regarless of records returns or order or what ever!
Cheers,
Alex
SELECT w.url, ROW_NUMBER() OVER (ORDER BY w.url ASC)
FROM Company c, Website w, Users u
WHERE w.companyID = c.companyID AND c.userID = u.userID AND u.userID = 23
精彩评论