user5278560 user5278560 - 1 year ago 62
MySQL Question

SQL - How Can I Use Returned Table, and add INNER JOIN and WHERE Clause in MySQL?

I wrote a sql query, and it returned me following table:

TitleName TitleCount
Title1 2
Title2 1

I want to use this returned table again, for example, I want to INNER JOIN with another returned table, or use WHERE clause like:

WHERE TitleName='Title1'

I tried:

SELECT column_name FROM (returned_table) INNER JOIN (returned_table_2) ON ...

It doesn't work, it says that I'm using SELECT keyword twice.

Answer Source

If I'm understanding correctly, just use a subquery:

select *
from (returned_table) t
where titlename = 'Title1'

With that said, you should be able to add where criteria to your existing query to limit it to Title1.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download