I just try following query:
SELECT *,
(
SELECT count(*)
FROM users
where users.email=calls.email
) as ureg,
(
SELECT sum(qty)
FROM product
where product.owner in
(SELECT *
from users
where users.email=calls.email)
) as pop
FROM calls
order by calls.data desc
LIMIT 0,20
but I get following error :
#1241 - Operand should contain 1 column(s)
How should I fix my query?
Edit:
by changing
SELECT * from users where users.email=calls.email
to
SELECT id from users where users.email=calls.email
it works because the query searches for product.owner in bunch of id
s that exist in users
ˈe-rər. : an act or condition of ignorant or imprudent deviation from a code of behavior. : an act involving an unintentional deviation from truth or accuracy. made an error in adding up the bill.
Some common synonyms of error are blunder, lapse, mistake, and slip.
An error may be defined as the difference between the measured and actual values. For example, if the two operators use the same device or instrument for measurement. It is not necessary that both operators get similar results. The difference between the measurements is referred to as an ERROR.
Both refer to doing something wrong. However, 'mistake' is less formal and it is insignificant compared to an 'error'. People make mistakes when they already have the knowledge but lack concern and attention. However, 'error' is more formal and when people have errors, it is because the lack the proper knowledge.
where product.owner in (SELECT *
product.owner
is one column, so the subquery should return one column (whatever corresponds to product.owner
).
try this
SELECT calls.*, count(users.*) as ureg, sum(twons.qty) as pop
FROM calls
INNER JOIN users ON users.email=calls.email
INNER JOIN towns ON towns.id = users.town
^^^^^^^^^^^^^^^^^^^^^^^^^^--you have to correct this to your table column names
order by data desc
LIMIT 0,20
ON towns.id = users.town
to your tables names If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With