Selecting data from another table using a foreign key I have two tables A &amp; B.
Table A
id | name | num

Table B
id | date | roll

id in table B is a foreign key which relates to the id in table A.
I want to get the contents of table B where id is given and also along with that data, I need the name whose id is given from table A.
NOTE: cannot use multiple queries separated by commas; need to do both the SELECTs in one query.
Joining tables is a fundamental principle of relational databases. In your case, A and B are related with the id column, which means that you can use a syntax similar to this one:

SELECT a.id, a.name, a.num, b.date, b.roll
FROM a
INNER JOIN b ON a.id=b.id;


INNER JOIN means that you'll only see rows where there are matching records in A and B. If you want all the rows in A and matching records in B, you could change INNER JOIN to LEFT JOIN. Conversely, if you want all the records from B and only the matching ones from A, use RIGHT JOIN. Finally, if you need everything from both tables, matching or not, you can use FULL JOIN.