All pastes #26616 Raw Edit

Mine

public text v1 · immutable
#26616 ·published 2005-10-25 15:28 UTC
rendered paste body
-----
table A:

id int(11) auto_increment,
name varchar(25)

-----
table B:
a_id int(11),
b_num int(11)

-----

can I optimize this?
SELECT a_id FROM B WHERE b_num = '31337';

loop: and based on the result, I fetch name for that ID from table A:
SELECT name FROM A WHERE id = $a_id;