[INST] Here is a database schema:
atom :
atom_id [ TEXT ] primary_key
molecule_id [ TEXT ] atom.molecule_id = molecule.molecule_id
element [ TEXT ]

bond :
bond_id [ TEXT ] primary_key
molecule_id [ TEXT ] bond.molecule_id = molecule.molecule_id
bond_type [ TEXT ]

connected :
atom_id [ TEXT ] connected.atom_id = atom.atom_id
atom_id2 [ TEXT ] connected.atom_id2 = atom.atom_id
bond_id [ TEXT ] connected.bond_id = bond.bond_id

molecule :
molecule_id [ TEXT ] primary_key
label [ TEXT ]

Please write me a SQL statement that answers the following question: How many bonds which involved atom 12 does molecule TR009 have? [/INST]
SELECT COUNT(T2.bond_id) FROM bond AS T1 INNER JOIN connected AS T2 ON T1.bond_id = T2.bond_id WHERE T1.molecule_id = 'TR009' AND T2.atom_id = T1.molecule_id || '_1' AND T2.atom_id2 = T1.molecule_id || '_2';