I have 2 tables, table A and table B.
Table A has these fields:
id(primary key),
references_id
Table B also has fields:
id(primary_key)
references_id.
Now I am given the ids of A, I need to retrieve A.id and the count(B.references_id) by A.references_id.
How can I do that in a SQL query?
Use
LEFT JOINso it will still show even if thereferences_idis not present on tableB. Try something like this,