Where subquery failed. This post was last edited by u010572351 at 17:14:25
Select goods_id, cat_id, goods_name from goods where goods_id =
(Select max (goods_id) from goods );
The statement is correct! However:
Query the last added item information in the item table (maximum goods_id ),
I understand the concept, but the condition value after the where condition is a select statement. although he returns a maximum value, it is a select statement and should be a result set, it's not an int. how can I compare it with goods_id? Stopped.
Reply to discussion (solution)
If a single result is in the result set, the = symbol can be used.
If there are multiple results, they are often written in. Generally, they are based on their own needs. in this way, we can basically determine what the subquery results are (single or multiple), and then select an appropriate operator.
In short, this is acceptable, because the result set has only one result.
If a single result is in the result set, the = symbol can be used.
If there are multiple results, they are often written in. Generally, they are based on their own needs. in this way, we can basically determine what the subquery results are (single or multiple), and then select an appropriate operator.
In short, this is acceptable, because the result set has only one result.
Yes, thank you!
The subquery result can be used as a condition for another query. when you have only one query result, you can use =
Yes, select max (goods_id) from goods) returns the record set
Goods_id = (select max (goods_id) from goods)
Goods_id in is also a record set (because each row has one)
Of course we can compare it.
Well, I will also write this query.