I want to the following using prepared statements:
<?php
$sql = "SELECT name FROM B WHERE profile_id IN (SELECT profile_id FROM A WHERE login_id='$email')
UNION SELECT name FROM C WHERE profile_id IN (SELECT profile_id FROM A WHERE login_id='$email')";
$result = mysqli_query($conn,$sql);
?>
Here, A
is the main table, B
and C
are sub tables. In the main table, the primary key is profile_id
. The tables B
and C
have a foreign key referencing A
's profile_id
.