You can query the tblWorkContent table, this gives all versions for a content item
SELECT Name FROM [SJA_Development_Episerver].[dbo].[tblWorkContent] where fkContentID = 23 AND Status = 4
Will get the current published version for the content id 23, however if you're looking for non published items you main need to get the latest saved version instead. I suggest you look at this table and understand it based on your needs
I know this is easily done from code, but i'm looking directly at the database with SQL.
I have the content ID and I want to find the page name from this, and if possible the page type name too.
Does anyone have a query that would get me this? Or even which tables I should be looking in?