Where subquery failed. This post was last edited by u010572351 from 2013-06-2817: 14: 25 & nbsp; select & nbsp; goods_id, cat_id, & nbsp; goods_name & nbsp; from & nbsp; goods & nbsp; where & nbsp; goods_id & nbsp; (select 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, he is a select statement. it should be a result set rather than an int. how can he compare it with goods_id?Stopped.
Share:
------ 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.
------ Solution --------------------
The subquery result can be used as a condition for another query. when you have only one query result, you can use =
------ Solution --------------------
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.