Have I lost it, but if feels like I remember doing something along the lines of:
select tb1.c1, (select count(tb2.c2) from tb2 where tb2.id = tb1.id) from tb1 where blah;
I can’t remember but I think did something like this maybe it wasn’t mysql.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
What was the question?
This statement looks valid, at least in MySQL 5.1 and later.
This may work in MySQL 5.0, but for sure not in MySQL 3.23.
You likely want to add an alias following the subquery, eg.
) AS tb2_count from