sql-subselect

How to subselect in where statement in SQL Server CE?

Hi, i have the following select statement to get the last login from the user table. this works very well under sqlite, now im porting the database and have Compact Edition from Microsoft. SELECT LOGIN FROM USERS WHERE LASTLOGIN = (SELECT MAX(LASTLOGIN) FROM USERS) The lastlogin column is datetime. This doesn't seems to work, w...

Find "old" rows

Consider a table like this: | txn_id | account_id I'd like to do a single query that will get me all txn_ids for all transactions where the transaction is not the most recent (highest txn_id) for the account_id . The database is MySQL 5.1, so that might imply some limitations around sub-selects. ...

A better way to build this MySQL statement with subselects

I have five tables in my database. Members, items, comments, votes and countries. I want to get 10 items. I want to get the count of comments and votes for each item. I also want the member that submitted each item, and the country they are from. After posting here and elsewhere, I started using subselects to get the counts, but this q...