My web site is a cafeteria. The user logs in and orders. When the same user logs in twice, the sub query error appears. What are the possible ways to solve the sub query problem?
If your subquery returns more than a single row, you can use an IN
clause to manage more rows:
select * from my_table
where id in (select id from table2 where ....)
Or you can obtain a single result using an aggregation function:
select * from my_table
where id = (select max(id) from table2 where ....)