Multiple selects and comparisons in sql -
string sql = " select name, surname, orderid, customerid, priority, status, date, time orders o o.customerid in " + "(select loggedin customers loggedin=1)";
i have 2 tables 1 called customer , 1 called orders. in customer table want retrieve people logged in system , match orders table see if have orders pending well. both of these tables contain customerid column contain same values. however, not sure how use , carry out logged in check in 1 statement. above 1 of attempts have made incorrect needs add join customerid's unsure carry out. in addition, sql driver using apache derby in case wondering
your query fine need select "customerid" @ end
... in ( select customerid customers loggedin=1 )
but recommend user joins. see users have pending orders:
select c.* customers c inner join orders o on o.customerid = c.customerid c.loggedid = 1 group c.customerid
to see pending orders user:
select * orders o inner join customer c on o.customerid = c.customerid , c.loggedid = 1