sql-select

Oracle correlated subquery in FROM list

I just tried to do a correlated subquery in the FROM clause of a SELECT statement in Oracle, but I was given an error indicating that I couldn't do the correlation (something to the effect that Obs.pID was not recognized). Should this work? FROM ml.Person Person JOIN ml.Obs ON Person.pID = Obs.pId JOIN (SELECT ObsMax2.pId, ObsMax2.h...

PostgreSQL: Using subquery abbreviation ('AS') in the WHERE clause

Hi, Consider the following query in PostgreSQL: SELECT a, b, (A VERY LONG AND COMPLICATED SUBQUERY) AS c, (ANOTHER VERY LONG AND COMPLICATED SUBQUERY) AS d FROM table I want to have c and d in the WHERE clause, like: WHERE c AND d; But, as far as I know, I can only do: WHERE A VERY LONG AND COMPLICATED SUBQUERY) AND ...

How to Create MySQL Query to Find Related Posts from Multiple Tables?

This is a complicated situation (for me) that I'm hopeful someone on here can help me with. I've done plenty of searching for a solution and have not been able to locate one. This is essentially my situation... (I've trimmed it down because if someone can help me to create this query I can take it from there.) TABLE articles (article...

How to join tables easily Microsoft SQL Server?

I have two separate tables used for categories. One is Categories(ID, Title, Description), and the other is SubCategories(ID, UpperID, Title, Description) I want to insert the records from categories to SubCategories with upperID=0. I've looked at SQL SELECT INTO but don't know how to use it for existing tables. ...