简体   繁体   中英

How can I use a table value in a WHERE clause in a SQL query?

I have this SQL query:

select *
from table 
inner join tableTwo 
on tableTwo.column = table.column
where columnTwo='THIS IS FIRST VALUE OF THIS COLUMN'
order by date DESC

On the Where clause, I want to use the result of this query:

select *
from table 
inner join tableTwo 
on tableTwo.column = table.column

This query produces a table with a column name of columnTwo. I want to use the data under column two in the WHERE clause like WHERE columnTwo={{ColumnData}}. How can I specifically achieve this? Sorry if my wording is bad, I am new to SQL.

https://dev.mysql.com/doc/refman/5.5/en/limit-optimization.html

SELECT * FROM table INNER JOIN tableTwo on tableTwo.column = table.column LIMIT 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM